Skip to content

Commit

Permalink
Merge branch 'agilgur5-object-hash-update'
Browse files Browse the repository at this point in the history
  • Loading branch information
ezolenko committed Feb 11, 2020
2 parents 947da25 + 3d3e4eb commit 6c4e53e
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 43 deletions.
41 changes: 23 additions & 18 deletions dist/rollup-plugin-typescript2.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -23537,22 +23537,25 @@ var hashes = crypto.getHashes ? crypto.getHashes().slice() : ['sha1', 'md5'];
hashes.push('passthrough');
var encodings = ['buffer', 'hex', 'binary', 'base64'];

function applyDefaults(object, options){
options = options || {};
options.algorithm = options.algorithm || 'sha1';
options.encoding = options.encoding || 'hex';
options.excludeValues = options.excludeValues ? true : false;
function applyDefaults(object, sourceOptions){
sourceOptions = sourceOptions || {};

// create a copy rather than mutating
var options = {};
options.algorithm = sourceOptions.algorithm || 'sha1';
options.encoding = sourceOptions.encoding || 'hex';
options.excludeValues = sourceOptions.excludeValues ? true : false;
options.algorithm = options.algorithm.toLowerCase();
options.encoding = options.encoding.toLowerCase();
options.ignoreUnknown = options.ignoreUnknown !== true ? false : true; // default to false
options.respectType = options.respectType === false ? false : true; // default to true
options.respectFunctionNames = options.respectFunctionNames === false ? false : true;
options.respectFunctionProperties = options.respectFunctionProperties === false ? false : true;
options.unorderedArrays = options.unorderedArrays !== true ? false : true; // default to false
options.unorderedSets = options.unorderedSets === false ? false : true; // default to false
options.unorderedObjects = options.unorderedObjects === false ? false : true; // default to true
options.replacer = options.replacer || undefined;
options.excludeKeys = options.excludeKeys || undefined;
options.ignoreUnknown = sourceOptions.ignoreUnknown !== true ? false : true; // default to false
options.respectType = sourceOptions.respectType === false ? false : true; // default to true
options.respectFunctionNames = sourceOptions.respectFunctionNames === false ? false : true;
options.respectFunctionProperties = sourceOptions.respectFunctionProperties === false ? false : true;
options.unorderedArrays = sourceOptions.unorderedArrays !== true ? false : true; // default to false
options.unorderedSets = sourceOptions.unorderedSets === false ? false : true; // default to false
options.unorderedObjects = sourceOptions.unorderedObjects === false ? false : true; // default to true
options.replacer = sourceOptions.replacer || undefined;
options.excludeKeys = sourceOptions.excludeKeys || undefined;

if(typeof object === 'undefined') {
throw new Error('Object argument required.');
Expand Down Expand Up @@ -23605,8 +23608,9 @@ function hash(object, options) {

var hasher = typeHasher(options, hashingStream);
hasher.dispatch(object);
if (!hashingStream.update)
if (!hashingStream.update) {
hashingStream.end('');
}

if (hashingStream.digest) {
return hashingStream.digest(options.encoding === 'buffer' ? undefined : options.encoding);
Expand Down Expand Up @@ -23642,10 +23646,11 @@ exports.writeToStream = function(object, options, stream) {
function typeHasher(options, writeTo, context){
context = context || [];
var write = function(str) {
if (writeTo.update)
if (writeTo.update) {
return writeTo.update(str, 'utf8');
else
} else {
return writeTo.write(str, 'utf8');
}
};

return {
Expand Down Expand Up @@ -23688,7 +23693,7 @@ function typeHasher(options, writeTo, context){
return write(object);
}

if(objType !== 'object' && objType !== 'function') {
if(objType !== 'object' && objType !== 'function' && objType !== 'asyncfunction') {
if(this['_' + objType]) {
this['_' + objType](object);
} else if (options.ignoreUnknown) {
Expand Down
2 changes: 1 addition & 1 deletion dist/rollup-plugin-typescript2.cjs.js.map

Large diffs are not rendered by default.

41 changes: 23 additions & 18 deletions dist/rollup-plugin-typescript2.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -23531,22 +23531,25 @@ var hashes = crypto.getHashes ? crypto.getHashes().slice() : ['sha1', 'md5'];
hashes.push('passthrough');
var encodings = ['buffer', 'hex', 'binary', 'base64'];

function applyDefaults(object, options){
options = options || {};
options.algorithm = options.algorithm || 'sha1';
options.encoding = options.encoding || 'hex';
options.excludeValues = options.excludeValues ? true : false;
function applyDefaults(object, sourceOptions){
sourceOptions = sourceOptions || {};

// create a copy rather than mutating
var options = {};
options.algorithm = sourceOptions.algorithm || 'sha1';
options.encoding = sourceOptions.encoding || 'hex';
options.excludeValues = sourceOptions.excludeValues ? true : false;
options.algorithm = options.algorithm.toLowerCase();
options.encoding = options.encoding.toLowerCase();
options.ignoreUnknown = options.ignoreUnknown !== true ? false : true; // default to false
options.respectType = options.respectType === false ? false : true; // default to true
options.respectFunctionNames = options.respectFunctionNames === false ? false : true;
options.respectFunctionProperties = options.respectFunctionProperties === false ? false : true;
options.unorderedArrays = options.unorderedArrays !== true ? false : true; // default to false
options.unorderedSets = options.unorderedSets === false ? false : true; // default to false
options.unorderedObjects = options.unorderedObjects === false ? false : true; // default to true
options.replacer = options.replacer || undefined;
options.excludeKeys = options.excludeKeys || undefined;
options.ignoreUnknown = sourceOptions.ignoreUnknown !== true ? false : true; // default to false
options.respectType = sourceOptions.respectType === false ? false : true; // default to true
options.respectFunctionNames = sourceOptions.respectFunctionNames === false ? false : true;
options.respectFunctionProperties = sourceOptions.respectFunctionProperties === false ? false : true;
options.unorderedArrays = sourceOptions.unorderedArrays !== true ? false : true; // default to false
options.unorderedSets = sourceOptions.unorderedSets === false ? false : true; // default to false
options.unorderedObjects = sourceOptions.unorderedObjects === false ? false : true; // default to true
options.replacer = sourceOptions.replacer || undefined;
options.excludeKeys = sourceOptions.excludeKeys || undefined;

if(typeof object === 'undefined') {
throw new Error('Object argument required.');
Expand Down Expand Up @@ -23599,8 +23602,9 @@ function hash(object, options) {

var hasher = typeHasher(options, hashingStream);
hasher.dispatch(object);
if (!hashingStream.update)
if (!hashingStream.update) {
hashingStream.end('');
}

if (hashingStream.digest) {
return hashingStream.digest(options.encoding === 'buffer' ? undefined : options.encoding);
Expand Down Expand Up @@ -23636,10 +23640,11 @@ exports.writeToStream = function(object, options, stream) {
function typeHasher(options, writeTo, context){
context = context || [];
var write = function(str) {
if (writeTo.update)
if (writeTo.update) {
return writeTo.update(str, 'utf8');
else
} else {
return writeTo.write(str, 'utf8');
}
};

return {
Expand Down Expand Up @@ -23682,7 +23687,7 @@ function typeHasher(options, writeTo, context){
return write(object);
}

if(objType !== 'object' && objType !== 'function') {
if(objType !== 'object' && objType !== 'function' && objType !== 'asyncfunction') {
if(this['_' + objType]) {
this['_' + objType](object);
} else if (options.ignoreUnknown) {
Expand Down
2 changes: 1 addition & 1 deletion dist/rollup-plugin-typescript2.es.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"colors": "1.3.3",
"graphlib": "2.1.7",
"lodash": "4.17.15",
"object-hash": "1.3.1",
"object-hash": "2.0.2",
"rimraf": "3.0.0",
"rollup": "^1.26.3 ",
"rollup-plugin-commonjs": "10.1.0",
Expand Down

0 comments on commit 6c4e53e

Please sign in to comment.