Comparing version 0.1.5 to 0.1.6
'use strict'; | ||
var alias = { | ||
const alias = { | ||
eq: 'equal', | ||
@@ -20,5 +20,3 @@ ne: 'notEqual', | ||
var isSubset = function (derived, base, verified) { | ||
var i; | ||
const isSubset = function (derived, base, verified) { | ||
if (!verified) { | ||
@@ -28,3 +26,3 @@ verified = []; | ||
for (i in derived) { | ||
for (const i in derived) { | ||
if (verified.indexOf(derived[i]) === -1) { | ||
@@ -39,3 +37,3 @@ if (typeof derived[i] === 'object') { | ||
/*eslint-disable no-use-before-define*/ | ||
/* eslint-disable no-use-before-define */ | ||
if (typeof derived[i] === 'object' && typeof base[i] === 'object' && derived[i] && base[i]) { | ||
@@ -54,11 +52,10 @@ if ( | ||
} | ||
/*eslint-enable no-use-before-define*/ | ||
/* eslint-enable no-use-before-define */ | ||
} | ||
} | ||
return true; | ||
}; | ||
var isSubsetStructure = function (derived, base, verified) { | ||
var i; | ||
const isSubsetStructure = function (derived, base, verified) { | ||
if (!verified) { | ||
@@ -68,3 +65,3 @@ verified = []; | ||
for (i in derived) { | ||
for (const i in derived) { | ||
if (verified.indexOf(derived[i]) === -1) { | ||
@@ -86,16 +83,9 @@ if (typeof derived[i] === 'object') { | ||
var bind = function (f, obj) { | ||
return function () { | ||
return f.apply(obj, arguments); | ||
const wrap = function (fn1, fn2) { | ||
return function (...args) { | ||
return Reflect.apply(fn2, this, [ fn1, ...args ]); | ||
}; | ||
}; | ||
var wrap = function (f, g) { | ||
return function () { | ||
var args = [ f ].concat(Array.prototype.slice.call(arguments, 0)); | ||
return g.apply(this, args); | ||
}; | ||
}; | ||
var unwrap = function (obj) { | ||
const unwrap = function (obj) { | ||
if (obj === null) { | ||
@@ -110,10 +100,10 @@ return obj; | ||
var processTypes = function (f, first, second) { | ||
const processTypes = function (fn, first, second) { | ||
first = unwrap(first); | ||
second = unwrap(second); | ||
return f(first, second); | ||
return fn(first, second); | ||
}; | ||
var processTypesStructure = function (f, first, second) { | ||
const processTypesStructure = function (fn, first, second) { | ||
if (typeof first !== 'object' || typeof second !== 'object') { | ||
@@ -127,7 +117,7 @@ return false; | ||
return f(first, second); | ||
return fn(first, second); | ||
}; | ||
var cmp = { | ||
eq: function (first, second) { | ||
const cmp = { | ||
eq (first, second) { | ||
// If two functions shall be compared, compare their source code. | ||
@@ -154,3 +144,3 @@ if (typeof first === 'function' && typeof second === 'function') { | ||
eqs: function (first, second) { | ||
eqs (first, second) { | ||
// If exactly one is null, they are not equal by structure. | ||
@@ -169,11 +159,11 @@ if ((first && !second) || (!first && second)) { | ||
ne: function (first, second) { | ||
return !(this.eq(first, second)); | ||
ne (first, second) { | ||
return !this.eq(first, second); | ||
}, | ||
nes: function (first, second) { | ||
return !(this.eqs(first, second)); | ||
nes (first, second) { | ||
return !this.eqs(first, second); | ||
}, | ||
gt: function (first, second) { | ||
gt (first, second) { | ||
// If at least one parameter is a function, greater than does not make sense. | ||
@@ -197,3 +187,3 @@ if (typeof first === 'function' || typeof second === 'function') { | ||
gts: function (first, second) { | ||
gts (first, second) { | ||
// If the second object is null, the first is greater by structure. | ||
@@ -214,11 +204,11 @@ if (first && !second) { | ||
ge: function (first, second) { | ||
ge (first, second) { | ||
return this.gt(first, second) || this.eq(first, second); | ||
}, | ||
ges: function (first, second) { | ||
ges (first, second) { | ||
return this.gts(first, second) || this.eqs(first, second); | ||
}, | ||
lt: function (first, second) { | ||
lt (first, second) { | ||
// If at least one parameter is a function, less than does not make sense. | ||
@@ -242,3 +232,3 @@ if (typeof first === 'function' || typeof second === 'function') { | ||
lts: function (first, second) { | ||
lts (first, second) { | ||
// If the first object is null, it is less by structure. | ||
@@ -259,11 +249,11 @@ if (!first && second) { | ||
le: function (first, second) { | ||
le (first, second) { | ||
return this.lt(first, second) || this.eq(first, second); | ||
}, | ||
les: function (first, second) { | ||
les (first, second) { | ||
return this.lts(first, second) || this.eqs(first, second); | ||
}, | ||
id: function (first, second) { | ||
id (first, second) { | ||
// Functions and objects need to be compared by reference, all other types are compared by value. | ||
@@ -279,8 +269,7 @@ if ((typeof first === 'function' && typeof second === 'function') || | ||
var setupFunction = function (comparer, f) { | ||
return wrap(bind(comparer, cmp), f); | ||
const setupFunction = function (comparer, fn) { | ||
return wrap(comparer.bind(cmp), fn); | ||
}; | ||
var j; | ||
for (j in cmp) { | ||
for (const j in cmp) { | ||
if (cmp.hasOwnProperty(j)) { | ||
@@ -287,0 +276,0 @@ if (j.length === 3) { |
{ | ||
"name": "comparejs", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "comparejs implements JavaScript's comparison operators the way you would expect them to be.", | ||
@@ -19,7 +19,7 @@ "contributors": [ | ||
], | ||
"main": "lib/compare.js", | ||
"main": "dist/compare.js", | ||
"devDependencies": { | ||
"grunt": "0.4.5", | ||
"should": "5.1.0", | ||
"tourism": "0.15.0" | ||
"roboter": "0.14.6", | ||
"roboter-server": "0.14.6", | ||
"should": "11.2.0" | ||
}, | ||
@@ -26,0 +26,0 @@ "repository": { |
@@ -7,3 +7,5 @@ # comparejs | ||
$ npm install comparejs | ||
```bash | ||
$ npm install comparejs | ||
``` | ||
@@ -15,3 +17,3 @@ ## Quick Start | ||
```javascript | ||
var cmp = require('comparejs'); | ||
const cmp = require('comparejs'); | ||
``` | ||
@@ -67,5 +69,7 @@ | ||
This module can be built using [Grunt](http://gruntjs.com/). Besides running the tests, this also analyses the code. To run Grunt, go to the folder where you have installed comparejs and run `grunt`. You need to have [grunt-cli](https://github.com/gruntjs/grunt-cli) installed. | ||
To build this module use [roboter](https://www.npmjs.com/package/roboter). | ||
$ grunt | ||
```bash | ||
$ bot | ||
``` | ||
@@ -75,3 +79,3 @@ ## License | ||
The MIT License (MIT) | ||
Copyright (c) 2012-2015 the native web. | ||
Copyright (c) 2012-2017 the native web. | ||
@@ -78,0 +82,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
164044
20
5675
83
4