Comparing version 9.7.0 to 9.7.1
{ | ||
"name": "utilsac", | ||
"version": "9.7.0", | ||
"description": "JavaScript General Purpose Utility Functions", | ||
"version": "9.7.1", | ||
"description": "Utility functions", | ||
"main": "files.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "echo see tests" | ||
}, | ||
@@ -12,5 +12,4 @@ "keywords": [ | ||
"files", | ||
"random" | ||
"random" | ||
], | ||
"author": "GrosSacASacs", | ||
"license": "CC0-1.0", | ||
@@ -17,0 +16,0 @@ "repository": { |
@@ -1,3 +0,7 @@ | ||
# JavaScript General Purpose Utility Functions | ||
# Utility functions | ||
## Installation | ||
[`npm i utilsac`](https://www.npmjs.com/package/utilsac) | ||
## utilsac | ||
@@ -72,3 +76,3 @@ | ||
[CC0](license.txt) | ||
[CC0](./license.txt) | ||
@@ -75,0 +79,0 @@ ### Related |
@@ -24,4 +24,3 @@ export { | ||
the returned function always returns undefined | ||
*/ | ||
the returned function always returns undefined */ | ||
let timeOutId = 0; | ||
@@ -45,4 +44,3 @@ return function(...args) { | ||
the returned function always returns undefined | ||
*/ | ||
the returned function always returns undefined */ | ||
let lastTime = Number.MIN_SAFE_INTEGER; | ||
@@ -67,4 +65,3 @@ return function(...args) { | ||
the returned function always returns undefined | ||
*/ | ||
the returned function always returns undefined */ | ||
@@ -98,4 +95,3 @@ let timeOutId = 0; | ||
the returned function always return undefined | ||
*/ | ||
the returned function always return undefined */ | ||
let ready = true; | ||
@@ -139,7 +135,6 @@ const makeReady = function() { | ||
const arrayWithResults = function (aFunction, times) { | ||
/* [].fill is for static values only | ||
/* [].fill is for static values only | ||
alternative , return Array.from({length: times}, aFunction); | ||
same if aFunction ignores its second argument | ||
*/ | ||
same if aFunction ignores its second argument */ | ||
const array = []; | ||
@@ -159,5 +154,5 @@ for (let i = 0; i < times; i += 1) { | ||
const chainPromises = function (promiseCreators) { | ||
// different than Promise.all | ||
// only executes promiseCreator one after the previous has resolved | ||
// resolves with an array of values | ||
/* different than Promise.all | ||
only executes promiseCreator one after the previous has resolved | ||
resolves with an array of values */ | ||
const length = promiseCreators.length; | ||
@@ -207,9 +202,9 @@ const values = []; | ||
const chainPromiseNTimes = function (promiseCreator, times) { | ||
// different than Promise.all | ||
// only executes promiseCreator one after the previous has resolved | ||
// useful for testing | ||
// resolves with an array of values | ||
/* different than Promise.all | ||
only executes promiseCreator one after the previous has resolved | ||
useful for testing | ||
resolves with an array of values | ||
// could be made with chainPromises, but chose not to | ||
// to avoid an adapter array | ||
could be made with chainPromises, but chose not to | ||
to avoid an adapter array */ | ||
const values = []; | ||
@@ -243,14 +238,12 @@ if (times === 0) { | ||
const timePromise = function (promiseCreator) { | ||
// returns a Promise that resolves with | ||
// the time elapsed for the promise to resolve and its value | ||
// executes promiseCreator and waits for it to resolve | ||
return new Promise(function (resolve, reject) { | ||
const startTime = performance.now(); | ||
promiseCreator().then(function (value) { | ||
const endTime = performance.now(); | ||
resolve({ | ||
timeElapsed: endTime - startTime, | ||
value | ||
}); | ||
}).catch(reject); | ||
/* returns a Promise that resolves with | ||
the time elapsed for the promise to resolve and its value | ||
executes promiseCreator and waits for it to resolve */ | ||
const startTime = performance.now(); | ||
return promiseCreator().then(function (value) { | ||
const endTime = performance.now(); | ||
return { | ||
timeElapsed: endTime - startTime, | ||
value | ||
}; | ||
}); | ||
@@ -260,9 +253,7 @@ }; | ||
const memoizeAsStrings = function (functionToMemoize, separator = "-") { | ||
/* | ||
joins together the args as strings to | ||
const memoizeAsStrings = function (functionToMemoize, separator = `-`) { | ||
/* joins together the args as strings to | ||
decide if arguments are the same | ||
fast memoizer | ||
but infinitely growing | ||
*/ | ||
but infinitely growing */ | ||
@@ -290,3 +281,3 @@ const previousResults = {}; | ||
const deepCopy = x => { | ||
if (!x || typeof x !== "object") { | ||
if (!x || typeof x !== `object`) { | ||
return x; | ||
@@ -322,7 +313,7 @@ } | ||
sources.forEach(source => { | ||
if (!source || typeof source !== "object") { | ||
if (!source || typeof source !== `object`) { | ||
return; | ||
} | ||
Object.entries(source).forEach(([key, value]) => { | ||
if (!value || typeof value !== "object") { | ||
if (!value || typeof value !== `object`) { | ||
target[key] = value; | ||
@@ -335,3 +326,3 @@ return; | ||
// value is an Object | ||
if (typeof target[key] !== "object" || !target[key]) { | ||
if (typeof target[key] !== `object` || !target[key]) { | ||
target[key] = {}; | ||
@@ -338,0 +329,0 @@ } |
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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
27619
13
573
1
85
2
2