@applitools/functional-commons
Advanced tools
Comparing version 1.0.21 to 1.0.22
{ | ||
"name": "@applitools/functional-commons", | ||
"version": "1.0.21", | ||
"version": "1.0.22", | ||
"description": "", | ||
@@ -37,9 +37,9 @@ "main": "src/functional-commons.js", | ||
"chai": "^4.2.0", | ||
"eslint": "^5.8.0", | ||
"eslint-plugin-mocha-no-only": "^1.0.0", | ||
"eslint-plugin-node": "^7.0.1", | ||
"eslint-plugin-prettier": "^2.7.0", | ||
"eslint": "^5.12.0", | ||
"eslint-plugin-mocha-no-only": "^1.1.0", | ||
"eslint-plugin-node": "^8.0.1", | ||
"eslint-plugin-prettier": "^3.0.1", | ||
"mocha": "^5.2.0", | ||
"prettier": "^1.14.3" | ||
"prettier": "^1.15.3" | ||
} | ||
} |
@@ -74,2 +74,55 @@ 'use strict' | ||
/** | ||
* | ||
* @param {object} object | ||
* @param {(key:string) => boolean} filterFunc | ||
* | ||
* @returns {object} | ||
*/ | ||
function filterKeys(object, filterFunc) { | ||
const ret = {} | ||
for (const [k, v] of Object.entries(object)) { | ||
if (filterFunc(k)) { | ||
ret[k] = v | ||
} | ||
} | ||
return ret | ||
} | ||
/** | ||
* @param {object} object | ||
* @param {(value:any) => boolean} filterFunc | ||
* @returns {object} | ||
*/ | ||
function filterValues(object, filterFunc) { | ||
const ret = {} | ||
for (const [k, v] of Object.entries(object)) { | ||
if (filterFunc(v)) { | ||
ret[k] = v | ||
} | ||
} | ||
return ret | ||
} | ||
/** | ||
* @param {object} object | ||
* @param {(entry: [string, any]) => boolean} filterFunc | ||
* @returns {object} | ||
*/ | ||
function filterEntries(object, filterFunc) { | ||
const ret = {} | ||
for (const entry of Object.entries(object)) { | ||
if (filterFunc(entry)) { | ||
ret[entry[0]] = entry[1] | ||
} | ||
} | ||
return ret | ||
} | ||
async function failAfter(ms, errFactory) { | ||
@@ -106,4 +159,4 @@ await p(setTimeout)(ms) | ||
), | ||
p(setTimeout)(timeout).then( | ||
() => (promiseResolved ? undefined : ((promiseResolved = true), func())), | ||
p(setTimeout)(timeout).then(() => | ||
promiseResolved ? undefined : ((promiseResolved = true), func()), | ||
), | ||
@@ -163,2 +216,5 @@ ]) | ||
mapValues, | ||
filterKeys, | ||
filterValues, | ||
filterEntries, | ||
failAfter, | ||
@@ -165,0 +221,0 @@ presult, |
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
6638
208