typhonjs-escomplex-commons
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -67,3 +67,4 @@ 'use strict'; | ||
* | ||
* @param {function} method - A custom method to process each TraitHalstead data. | ||
* @param {function} callback - A custom method to process each TraitHalstead data. | ||
* @param {object} thisArg - The this `this` scope to run callback with. | ||
*/ | ||
@@ -74,4 +75,4 @@ | ||
key: 'forEach', | ||
value: function forEach(method) { | ||
this._data.forEach(method); | ||
value: function forEach(callback, thisArg) { | ||
this._data.forEach(callback, thisArg); | ||
} | ||
@@ -124,6 +125,19 @@ | ||
// Map all TraitHalstead data and flatten any array of identifiers returned from `valueOf`. | ||
// Map all TraitHalstead data and flatten any array of identifiers returned from `valueOf` and finally convert | ||
// all flattened identifiers to strings as necessary. | ||
return (_ref = []).concat.apply(_ref, _toConsumableArray(filtered.map(function (traitHalstead) { | ||
return traitHalstead.valueOf.apply(traitHalstead, params); | ||
}))); | ||
}))).map(function (entry) { | ||
// Convert any undefined entry to a text string. This should only be possible when a TraitHalstead defined | ||
// as a function returns an array containing `undefined`; in this case there is an issue with a syntax trait | ||
// definition not properly verifying data. | ||
/* istanbul ignore if */ | ||
if (entry === void 0) { | ||
console.warn('HalsteadArray valueOf warning: undefined TraitHalstead item entry converted to a \'string\'.'); | ||
entry = 'undefined'; | ||
} | ||
return typeof entry !== 'string' ? JSON.stringify(entry) : entry; | ||
}); | ||
} | ||
@@ -130,0 +144,0 @@ }, { |
@@ -109,3 +109,3 @@ 'use strict'; | ||
* | ||
* @returns {string|Array<string>} | ||
* @returns {*|Array<*>} | ||
*/ | ||
@@ -121,11 +121,7 @@ value: function valueOf() { | ||
return this._data.identifier.map(function (entry) { | ||
var value = typeof entry === 'function' ? entry.apply(undefined, params) : entry; | ||
return typeof value !== 'string' ? JSON.stringify(value) : value; | ||
return typeof entry === 'function' ? entry.apply(undefined, params) : entry; | ||
}); | ||
} | ||
var value = typeof this._data.identifier === 'function' ? (_data2 = this._data).identifier.apply(_data2, params) : this._data.identifier; | ||
return typeof value !== 'string' ? JSON.stringify(value) : value; | ||
return typeof this._data.identifier === 'function' ? (_data2 = this._data).identifier.apply(_data2, params) : this._data.identifier; | ||
} | ||
@@ -132,0 +128,0 @@ }, { |
{ | ||
"name": "typhonjs-escomplex-commons", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"homepage": "https://github.com/typhonjs-node-escomplex/typhonjs-escomplex-commons/", | ||
@@ -39,3 +39,4 @@ "description": "Provides core common utilities for typhonjs-escomplex modules and plugins.", | ||
"report", | ||
"traits" | ||
"traits", | ||
"formats" | ||
], | ||
@@ -42,0 +43,0 @@ "files": [ |
@@ -45,7 +45,8 @@ import TraitHalstead from './TraitHalstead'; | ||
* | ||
* @param {function} method - A custom method to process each TraitHalstead data. | ||
* @param {function} callback - A custom method to process each TraitHalstead data. | ||
* @param {object} thisArg - The this `this` scope to run callback with. | ||
*/ | ||
forEach(method) | ||
forEach(callback, thisArg) | ||
{ | ||
this._data.forEach(method); | ||
this._data.forEach(callback, thisArg); | ||
} | ||
@@ -103,5 +104,23 @@ | ||
// Map all TraitHalstead data and flatten any array of identifiers returned from `valueOf`. | ||
return [].concat(...filtered.map((traitHalstead) => { return traitHalstead.valueOf(...params); })); | ||
// Map all TraitHalstead data and flatten any array of identifiers returned from `valueOf` and finally convert | ||
// all flattened identifiers to strings as necessary. | ||
return ([].concat(...filtered.map((traitHalstead) => | ||
{ | ||
return traitHalstead.valueOf(...params); | ||
}))).map((entry) => | ||
{ | ||
// Convert any undefined entry to a text string. This should only be possible when a TraitHalstead defined | ||
// as a function returns an array containing `undefined`; in this case there is an issue with a syntax trait | ||
// definition not properly verifying data. | ||
/* istanbul ignore if */ | ||
if (entry === void 0) | ||
{ | ||
console.warn(`HalsteadArray valueOf warning: undefined TraitHalstead item entry converted to a 'string'.`); | ||
entry = 'undefined'; | ||
} | ||
return typeof entry !== 'string' ? JSON.stringify(entry) : entry; | ||
}); | ||
} | ||
} |
@@ -98,3 +98,3 @@ /** | ||
* | ||
* @returns {string|Array<string>} | ||
* @returns {*|Array<*>} | ||
*/ | ||
@@ -107,13 +107,8 @@ valueOf(...params) | ||
{ | ||
const value = typeof entry === 'function' ? entry(...params) : entry; | ||
return typeof value !== 'string' ? JSON.stringify(value) : value; | ||
return typeof entry === 'function' ? entry(...params) : entry; | ||
}); | ||
} | ||
const value = typeof this._data.identifier === 'function' ? this._data.identifier(...params) : | ||
this._data.identifier; | ||
return typeof value !== 'string' ? JSON.stringify(value) : value; | ||
return typeof this._data.identifier === 'function' ? this._data.identifier(...params) : this._data.identifier; | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
341038
7748