Merge branch 'agilgur5-object-hash-update'

This commit is contained in:
Eugene Zolenko 2020-02-11 16:05:44 -07:00
commit 6c4e53eeff
6 changed files with 53 additions and 43 deletions

View File

@ -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.');
@ -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);
@ -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 {
@ -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) {

File diff suppressed because one or more lines are too long

View File

@ -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.');
@ -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);
@ -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 {
@ -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) {

File diff suppressed because one or more lines are too long

8
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "rollup-plugin-typescript2",
"version": "0.25.2",
"version": "0.25.4",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -937,9 +937,9 @@
"optional": true
},
"object-hash": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/object-hash/-/object-hash-1.3.1.tgz",
"integrity": "sha512-OSuu/pU4ENM9kmREg0BdNrUDIl1heYa4mBZacJc+vVWz4GtAwu7jO8s4AIt2aGRUTqxykpWzI3Oqnsm13tTMDA==",
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/object-hash/-/object-hash-2.0.2.tgz",
"integrity": "sha512-b+2AKjAf6uQlxxv8ChHdM+VT4eeX+ZSwv+pk2xIXZWbo+yxn4/En1iC+GHe/OFYa9on0AhFF2PvuAcFHoiiHaA==",
"dev": true
},
"once": {

View File

@ -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",