diff --git a/lib/ArraySlice.js b/lib/ArraySlice.js index 1ab9c6c7..19e34716 100644 --- a/lib/ArraySlice.js +++ b/lib/ArraySlice.js @@ -1,4 +1,4 @@ -const negate = require('lodash/negate'); +const complement = require('ramda/src/complement'); // Coerces an a parameter into a callback for matching elements. // This accepts an element name, an element type and returns a @@ -99,7 +99,7 @@ class ArraySlice { */ reject(callback, thisArg) { callback = coerceElementMatchingCallback(callback); - return new ArraySlice(this.elements.filter(negate(callback), thisArg)); + return new ArraySlice(this.elements.filter(complement(callback), thisArg)); } /** diff --git a/lib/Namespace.js b/lib/Namespace.js index 48bb80bf..41679b45 100644 --- a/lib/Namespace.js +++ b/lib/Namespace.js @@ -1,9 +1,4 @@ -const isNull = require('lodash/isNull'); -const isString = require('lodash/isString'); -const isNumber = require('lodash/isNumber'); -const isBoolean = require('lodash/isBoolean'); -const isObject = require('lodash/isObject'); - +const is = require('ramda/src/is'); const JSONSerialiser = require('./serialisers/JSONSerialiser'); const elements = require('./elements'); @@ -68,12 +63,12 @@ class Namespace { // Add instance detection functions to convert existing objects into // the corresponding refract elements. this - .detect(isNull, elements.NullElement, false) - .detect(isString, elements.StringElement, false) - .detect(isNumber, elements.NumberElement, false) - .detect(isBoolean, elements.BooleanElement, false) - .detect(Array.isArray, elements.ArrayElement, false) - .detect(isObject, elements.ObjectElement, false); + .detect(v => v === null, elements.NullElement, false) + .detect(is(String), elements.StringElement, false) + .detect(is(Number), elements.NumberElement, false) + .detect(is(Boolean), elements.BooleanElement, false) + .detect(is(Array), elements.ArrayElement, false) + .detect(is(Object), elements.ObjectElement, false); return this; } diff --git a/lib/ObjectSlice.js b/lib/ObjectSlice.js index 795ee791..e2d27544 100644 --- a/lib/ObjectSlice.js +++ b/lib/ObjectSlice.js @@ -1,4 +1,4 @@ -const negate = require('lodash/negate'); +const complement = require('ramda/src/complement'); const ArraySlice = require('./ArraySlice'); /** @@ -13,7 +13,7 @@ class ObjectSlice extends ArraySlice { } reject(callback, thisArg) { - return this.filter(negate(callback.bind(thisArg))); + return this.filter(complement(callback.bind(thisArg))); } forEach(callback, thisArg) { diff --git a/lib/primitives/ArrayElement.js b/lib/primitives/ArrayElement.js index 5e64c8fc..ad9c23f7 100644 --- a/lib/primitives/ArrayElement.js +++ b/lib/primitives/ArrayElement.js @@ -1,4 +1,4 @@ -const negate = require('lodash/negate'); +const complement = require('ramda/src/complement'); const Element = require('./Element'); const ArraySlice = require('../ArraySlice'); @@ -118,7 +118,7 @@ class ArrayElement extends Element { * @returns {ArraySlice} */ reject(callback, thisArg) { - return this.filter(negate(callback), thisArg); + return this.filter(complement(callback), thisArg); } /** diff --git a/lib/primitives/Element.js b/lib/primitives/Element.js index b3e74c1d..4e75c005 100644 --- a/lib/primitives/Element.js +++ b/lib/primitives/Element.js @@ -1,4 +1,4 @@ -const isEqual = require('lodash/isEqual'); +const equals = require('ramda/src/equals'); const KeyValuePair = require('../KeyValuePair'); const ArraySlice = require('../ArraySlice.js'); @@ -219,7 +219,7 @@ class Element { } equals(value) { - return isEqual(this.toValue(), value); + return equals(this.toValue(), value); } getMetaProperty(name, value) { diff --git a/lib/primitives/ObjectElement.js b/lib/primitives/ObjectElement.js index 413c4f62..a547b0c3 100644 --- a/lib/primitives/ObjectElement.js +++ b/lib/primitives/ObjectElement.js @@ -1,6 +1,5 @@ -const negate = require('lodash/negate'); -const isObject = require('lodash/isObject'); - +const complement = require('ramda/src/complement'); +const is = require('ramda/src/is'); const ArrayElement = require('./ArrayElement'); const MemberElement = require('./MemberElement'); const ObjectSlice = require('../ObjectSlice'); @@ -90,7 +89,7 @@ class ObjectElement extends ArrayElement { * If an object is given, each key is set to its respective value */ set(keyOrObject, value) { - if (isObject(keyOrObject)) { + if (is(Object, keyOrObject)) { Object.keys(keyOrObject).forEach((objectKey) => { this.set(objectKey, keyOrObject[objectKey]); }); @@ -190,7 +189,7 @@ class ObjectElement extends ArrayElement { * @memberof ObjectElement.prototype */ reject(callback, thisArg) { - return this.filter(negate(callback), thisArg); + return this.filter(complement(callback), thisArg); } /** diff --git a/package.json b/package.json index c761a37d..a0571c0b 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "sinon": "^7.2.4" }, "dependencies": { - "lodash": "^4.15.0" + "ramda": "^0.26.1" }, "engines": { "node": ">=6"