![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Function argument and JSON schema type checking for Node.js
npm install filtrate
Wrap a function
var bar = filtrate(
[Number, {}, String],
function() {
console.log('bar', arguments);
}
);
bar(21, {a: 42}, "Test"); // executes foo.fn
bar(21, [a, 42], "Test"); // throws!
Modify an object method
var foo = {
fn: function() {
console.log('foo', arguments);
}
};
filtrate(foo, 'fn', [Number, Boolean]);
foo.fn(42, true); // executes foo.fn
foo.fn(42, 'string'); // throws!
Compare a pattern against a value
filtrate.compare(String, "Test"); //true
filtrate.compare(String, 42); //false
filtrate.compare([String, Number], ["Test", 42]); //true
filtrate.compare([String, Function], ["Test", 42]); //false
filtrate.compare(
{ a:String, b:Function },
{ a:"Test", b:Object.keys }); //false
filtrate.compare(
{ a:String, b:Function },
{ a:"Test", b:42 }); //false
Compare a pattern against a value with a helpful message
filtrate.check([String, Number], ["Test", 42]); //null
filtrate.check([String, Function], ["Test", 42]); //"Filtrate Error: input[1] is not a function (got: 42)"
patterns
, function
);Wrap a function
patterns
(Patterns Object
) - Patterns to match against (see below)
function
(Function
) - The function to be filtered
returns filtered function
object
, methodName
, patterns
);Modify object method
object
(Object
) - Parent object containing the method
methodName
(String
) - Name of the method
patterns
(Patterns Object
) - Patterns to match against (see below)
returns undefined
patterns
, input
);Pattern match, boolean result
input
(Function
) - An object to match
patterns
(Patterns Object
) - Patterns to match against (see below)
returns true
/false
patterns
, input
);Pattern match, string result
A patterns
object is recursively defined as:
patterns =
true ||
false ||
String ||
Number ||
Boolean ||
Function ||
Array ||
Object ||
undefined ||
[patterns, ...] ||
{key: patterns, ... }
true
is a truthy comparison
false
is a falsy comparison
String
, Number
, Boolean
, Function
, Array
and Object
are all essentially typeof
comparisons
undefined
skips comparison
[]
does a recursive comparison of these types listed
{}
does a recursive comparison of these types listed (also matches key names)
FAQs
Function argument and JSON schema type checking
The npm package filtrate receives a total of 0 weekly downloads. As such, filtrate popularity was classified as not popular.
We found that filtrate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.