New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

assert-op

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assert-op - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

index.js

5

CHANGELOG.md

@@ -11,4 +11,9 @@ <!-- markdownlint-disable MD012 MD022 MD024 MD026 MD032 MD041 -->

## [0.2.0] - 2018-11-04
### Changed
- cjs modules only
- unescape strings
## [0.1.0] - 2017-08-26
### Added
- First publish

11

package.json
{
"name": "assert-op",
"version": "0.1.0",
"version": "0.2.0",
"description": "assertions using comparison operators",
"keywords": ["unit test", "test", "assert"],
"author": "Hugo Villeneuve",
"main": "./dist/index.js",
"module": "./module.js",
"browser": "./dist/browser.js",
"main": "./index.js",
"private": false,

@@ -18,6 +16,3 @@ "repository": {

"scripts": {
"build": "npm run build:main & npm run build:browser",
"build:main": "rollup -o ./dist/index.js -f cjs --banner \"/* hugov@runbox.com | https://github.com/hville/cotest.git | license:MIT */\" ./module.js",
"build:browser": "rollup -o ./dist/browser.js -f iife -n assertOp --banner \"/* hugov@runbox.com | https://github.com/hville/cotest.git | license:MIT */\" ./module.js",
"test": "npm run build & node ./tst/assert",
"test": "node ./tst/assert & node ./tst/to-string",
"prepublishOnly": "npm test"

@@ -24,0 +19,0 @@ },

@@ -1,8 +0,10 @@

/* eslint-disable eqeqeq */
var testOwn = require('./test-own'),
testMap = require('./test-map'),
testSet = require('./test-set')
var maxDepth = 50 //for circular refs
export function deepEqual(val, ref, depth) {
module.exports = function deepEqual(val, ref, depth) {
// primitives check
if (val == ref) return true
if (val == ref) return true //eslint-disable-line eqeqeq
if (!val || typeof val !== 'object' || typeof ref !== 'object') return false

@@ -22,54 +24,1 @@

export function deepStrictEqual(val, ref, depth) {
// primitives check
if (val === ref) return true
if (!val || typeof val !== 'object' || typeof ref !== 'object') return false
if (depth === maxDepth) return false
// MAP: compare each value by key
if (typeof Map !== 'undefined' && val.constructor === Map) {
return testMap(val, ref, deepStrictEqual, depth ? ++depth : 1)
}
// SET: compare each value by order
if (typeof Set !== 'undefined' && val.constructor === Set) {
return testSet(val, ref, deepStrictEqual, depth ? ++depth : 1)
}
// object: own properties and strict Equal
var toStr = Object.prototype.toString
return Object.getPrototypeOf(val) === Object.getPrototypeOf(ref) &&
toStr.call(val) === toStr.call(ref) &&
testOwn(val, ref, deepStrictEqual, depth ? ++depth : 1)
}
function testOwn(val, ref, tst, depth) {
var kv = Object.keys(val),
kr = Object.keys(ref)
if (kv.length !== kr.length) return false
for (var i=0; i<kv.length; ++i) if (!tst(val[kv[i]], ref[kv[i]], depth)) return false
return true
}
function testMap(val, ref, tst, depth) {
if (ref.constructor !== Map || val.size!== ref.size) return false
var result = true
val.forEach(function(v,k) { if (result) result = tst(v, ref.get(k), depth) })
return result
}
function testSet(val, ref, tst, depth) {
if (ref.constructor !== Set || val.size!== ref.size) return false
return tst(setValues(val), setValues(ref), depth)
}
function setValues(set) {
var res = []
set.forEach(push, res)
return res
}
function push(v) { this.push(v) }

@@ -1,6 +0,9 @@

export function toString(val, max) {
module.exports = toString
function toString(val, max) {
var c = val && (val.constructor || Object),
t = c === Array ? '[' + val.map(toString) +']'
: c === Object ? ('{' + Object.keys(val).map(kv,val) + '}')
: ('' + val)
: c === Object ? ('{' + Object.keys(val).map(kv,val) + '}')
: c === String ? val.replace(/\f/g, '\\f').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/\t/g, '\\t')
: ('' + val)
return (max && t.length > max) ? Object.prototype.toString.call(val) : t

@@ -7,0 +10,0 @@ }

/* eslint no-console: 0, no-loop-func: 0*/
// @ts-ignore
var a = require('../dist/index.js')
var a = require('../')

@@ -5,0 +5,0 @@ //function logE(e) {console.log('ERR:',e.message); return true}

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