@factor/filters
Advanced tools
Comparing version 1.0.0-alpha.20 to 1.0.0-alpha.24
28
index.js
@@ -36,5 +36,4 @@ module.exports.default = Factor => { | ||
// https://github.com/WebReflection/flatted#flatted | ||
const { stringify } = require('flatted/cjs') | ||
const { stringify } = require("flatted/cjs") | ||
str = stringify(obj) | ||
} | ||
@@ -46,3 +45,8 @@ | ||
return str.split("").reduce((prevHash, currVal) => ((prevHash << 5) - prevHash + currVal.charCodeAt(0)) | 0, 0) | ||
return str | ||
.split("") | ||
.reduce( | ||
(prevHash, currVal) => ((prevHash << 5) - prevHash + currVal.charCodeAt(0)) | 0, | ||
0 | ||
) | ||
} | ||
@@ -112,3 +116,2 @@ | ||
this._filters[name][id] = { callback, context, priority } | ||
@@ -119,2 +122,17 @@ | ||
push(id, item, options = {}) { | ||
this.add( | ||
id, | ||
(_, args) => { | ||
item = typeof item == "function" ? item(args) : item | ||
if (Array.isArray(_)) { | ||
return [..._, item] | ||
} else if (typeof _ == "object") { | ||
return { ..._, [this.uniqueHash(item)]: item } | ||
} | ||
}, | ||
options | ||
) | ||
} | ||
// Add callbacks into an array of promises, meant to be used with $filters.run | ||
@@ -136,5 +154,3 @@ callback(id, callback, options = {}) { | ||
} | ||
})() | ||
} |
{ | ||
"name": "@factor/filters", | ||
"version": "1.0.0-alpha.20", | ||
"version": "1.0.0-alpha.24", | ||
"license": "GPL-2.0", | ||
@@ -9,3 +9,3 @@ "publishConfig": { | ||
"factor": {}, | ||
"gitHead": "e11cbda7b934f3aedf067d0e1b642491bc5f753d", | ||
"gitHead": "f68d8c51c38873d0a6b6c830d1461bf19bd926a9", | ||
"dependencies": { | ||
@@ -12,0 +12,0 @@ "flatted": "^2.0.1" |
Sorry, the diff of this file is not supported yet
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
23127
121