Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tmatch

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tmatch - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

.nyc_output/94400.json

45

index.js

@@ -13,28 +13,2 @@ 'use strict'

/**
1. If the object is a string, and the pattern is a RegExp, then return
true if `pattern.test(object)`.
2. Use loose equality (`==`) only for all other value types
(non-objects). `tmatch` cares more about shape and contents than
type. This step will also catch functions, with the useful
(default) property that only references to the same function are
considered equal. 'Ware the halting problem!
3. `null` *is* an object – a singleton value object, in fact – so if
either is `null`, return object == pattern.
4. Since the only way to make it this far is for `object` or `pattern`
to be an object, if `object` or `pattern` is *not* an object,
they're clearly not a match.
5. It's much faster to compare dates by numeric value (`.getTime()`)
than by lexical value.
6. Compare RegExps by their components, not the objects themselves.
7. The parts of an arguments list most people care about are the
arguments themselves, not the callee, which you shouldn't be
looking at anyway.
8. Objects are more complex:
1. Return `true` if `object` and `pattern` both have no properties.
2. Ensure that cyclical references don't blow up the stack.
3. Ensure that all the key names in `pattern` exist in `object`.
4. Ensure that all of the associated values match, recursively.
*/
/* istanbul ignore next */

@@ -47,5 +21,20 @@ var log = (/\btmatch\b/.test(process.env.NODE_DEBUG || '')) ?

if (obj == pattern) {
log('TMATCH same object or simple value, true')
return true
log('TMATCH same object or simple value, or problem')
// if one is object, and the other isn't, then this is bogus
if (obj === null || pattern === null) {
return true
} else if (typeof obj === 'object' && typeof pattern === 'object') {
return true
} else if (typeof obj === 'object' && typeof pattern !== 'object') {
return false
} else if (typeof obj !== 'object' && typeof pattern === 'object') {
return false
} else {
return true
}
} else if (obj === null || pattern === null) {

@@ -52,0 +41,0 @@ log('TMATCH null test, already failed ==')

{
"name": "tmatch",
"version": "2.0.0",
"version": "2.0.1",
"description": "This module exists to facilitate the `t.match()` method in [`tap`](http://npm.im/tap).",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -269,1 +269,11 @@ var tap = require('tap')

})
test('js WAT! array/string stuff', function (t) {
t.notOk(match([1], 1))
t.notOk(match(1, [1]))
t.ok(match([1], [1]))
var o = {}
t.ok(match(o, o))
t.ok(match(1, '1'))
t.end()
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc