Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
This module exists to facilitate the `t.match()` method in [`tap`](http://npm.im/tap).
This module exists to facilitate the t.match()
method in
tap
.
It checks whether a value matches a given "pattern". A pattern is an object with a set of fields that must be in the test object, or a regular expression that a test string must match, or any combination thereof.
The algorithm is borrowed heavily from
only-shallow
, with some notable
differences with respect to the handling of missing properties and the
way that regular expressions are compared to strings.
var matches = require('tmatch')
if (!matches(testObject, pattern)) console.log("yay! diversity!");
// somewhat more realistic example..
http.get(someUrl).on('response', function (res) {
var expect = {
statusCode: 200,
headers: {
server: /express/
}
}
if (!tmatch(res, expect)) {
throw new Error('Expect 200 status code from express server')
}
})
Copied from the source, here are the details of tmatch
's algorithm:
null
against undefined
, and avoids some stuff like 1 == [1]
.pattern.test(object)
, casting the object to a string if it is not
already a string.Set
, then return true if all the keys in
pattern
appear in object
.Map
, then return true if all the keys in
pattern
are in object
, and the values match as well.arguments
object, or the pattern is an
arguments
object, then cast them to arrays and compare their
contents.Buffer
constructor, then return true if
the object is a Buffer.Function
constructor, then return true if
the object is a function.instanceof
the pattern.undefined
, so it's possible to use {foo:null}
as a pattern
to ensure that the object doesn't have a foo
property.ISC. Go nuts.
FAQs
This module exists to facilitate the `t.match()` method in [`tap`](http://npm.im/tap).
We found that tmatch 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.