-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(lodash): Removes most of the lodash dependencies in favor of…
… native js (#117) * refactor(lodash): Removes most of the lodash dependencies in favor of native js Most of these lodash dependencies have a native replacement. The only reason they seem to have been used was to wrap the natives with safe checks and returns. For example the use of `_forEach(list, () => ...)` is a safe version of: ``` (list || []).forEach((item) => ...); ``` Lodash protects against undefined, null. Others such as _.map also protect by returning an empty map so that chaining is safely allowed, some es6 doesn't allow native. * Version bump to 2.1.0 in prep of release
- Loading branch information
Showing
9 changed files
with
102 additions
and
90 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = { | ||
hasOwnProp(source, propertyName) { | ||
return Object.prototype.hasOwnProperty.call(source, propertyName); | ||
}, | ||
|
||
isFunction(value) { | ||
return typeof value === 'function'; | ||
}, | ||
|
||
isObject(value) { | ||
const type = typeof value; | ||
return value != null && (type === 'object' || type === 'function'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const Utils = require('../../src/Utils'); | ||
|
||
describe('Utils', function () { | ||
describe('hasOwnProp', () => { | ||
it('should return true if the source object has the specified property', () => { | ||
const source = { name: 'John', age: 30 }; | ||
const propertyName = 'name'; | ||
const result = Utils.hasOwnProp(source, propertyName); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
it('should return false if the source object does not have the specified property', () => { | ||
const source = { name: 'John', age: 30 }; | ||
const propertyName = 'address'; | ||
const result = Utils.hasOwnProp(source, propertyName); | ||
expect(result).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('isFunction', () => { | ||
it('should return true if the value is a function', () => { | ||
const value = () => {}; | ||
const result = Utils.isFunction(value); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
it('should return false if the value is not a function', () => { | ||
const value = 'Hello, World!'; | ||
const result = Utils.isFunction(value); | ||
expect(result).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('isObject', () => { | ||
it('should return true if the value is an object', () => { | ||
const value = { name: 'John', age: 30 }; | ||
const result = Utils.isObject(value); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
it('should return false if the value is not an object', () => { | ||
const value = 'Hello, World!'; | ||
const result = Utils.isObject(value); | ||
expect(result).toBe(false); | ||
}); | ||
}); | ||
|
||
}); |