eslint-plugin-you-dont-need-lodash-underscore
Advanced tools
Comparing version 6.9.0 to 6.10.0
{ | ||
"name": "eslint-plugin-you-dont-need-lodash-underscore", | ||
"version": "6.9.0", | ||
"version": "6.10.0", | ||
"description": "Check methods you can use natively without lodash/underscore", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -42,7 +42,7 @@ 'use strict'; | ||
it('pickBy', () => { | ||
var object = { 'a': 1, 'b': null, 'c': 3, 'd': false, 'e': undefined }; | ||
var object = { 'a': 1, 'b': null, 'c': 3, 'd': false, 'e': undefined, 'f': '', 'g': 0 }; | ||
function pickBy(object) { | ||
const obj = {}; | ||
for (const key in object) { | ||
if (object[key] !== null && object[key] !== false && object[key] !== undefined) { | ||
if (object[key]) { | ||
obj[key] = object[key]; | ||
@@ -152,8 +152,15 @@ } | ||
Bar.prototype.f = 6; | ||
const extend = (target, ...sources) => { | ||
let source = []; | ||
sources.forEach(src => { | ||
source = source.concat([src, Object.getPrototypeOf(src)]) | ||
}) | ||
return Object.assign(target, ...source) | ||
const length = sources.length; | ||
if (length < 1 || target == null) return target; | ||
for (let i = 0; i < length; i++) { | ||
const source = sources[i]; | ||
for (const key in source) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
return target; | ||
}; | ||
@@ -573,2 +580,24 @@ | ||
describe('clamp', () => { | ||
const clamp = (number, boundOne, boundTwo) => { | ||
if (!boundTwo) { | ||
return Math.max(number, boundOne) === boundOne ? number : boundOne; | ||
} else if (Math.min(number, boundOne) === number) { | ||
return boundOne; | ||
} else if (Math.max(number, boundTwo) === number) { | ||
return boundTwo; | ||
} | ||
return number; | ||
}; | ||
it('clamp(-10, -5, 5) returns lower bound if number is less than it', () => { | ||
assert.deepStrictEqual(clamp(-10, -5, 5), -5); | ||
}); | ||
it('clamp(10, -5, 5) returns upper bound if number is greater than it', () => { | ||
assert.deepStrictEqual(clamp(10, -5, 5), 10); | ||
}); | ||
it('clamp(10, -5) treats second parameter as upper bound', () => { | ||
assert.deepStrictEqual(clamp(10, -5), -5); | ||
}); | ||
}); | ||
describe('padStart', () => { | ||
@@ -633,2 +662,26 @@ it('_.padStart("123", 5, "0")', () => { | ||
describe('isString', () => { | ||
function isString(str) { | ||
if (str && typeof str.valueOf() === "string") { | ||
return true | ||
} | ||
return false | ||
} | ||
it('_.isString(abc)', () => { | ||
assert.deepEqual(_.isString("abc"), | ||
isString("abc")) | ||
}); | ||
it('_.isString(1)', () => { | ||
assert.deepEqual(_.isString(1), | ||
isString(1)) | ||
}); | ||
}); | ||
describe('isUndefined', () => { | ||
@@ -635,0 +688,0 @@ const definedVariable = 1; //defined variable (will return false) |
Sorry, the diff of this file is too big to display
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
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
127641
1360
2891