Skip to content

Commit

Permalink
chore: fully migrate to let/const
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku authored and fake-join[bot] committed Aug 30, 2021
1 parent ee16167 commit 51443fe
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 159 deletions.
22 changes: 11 additions & 11 deletions lib/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function find(collection, matcher) {

matcher = toMatcher(matcher);

var match;
let match;

forEach(collection, function(val, key) {
if (matcher(val, key)) {
Expand All @@ -46,7 +46,7 @@ export function findIndex(collection, matcher) {

matcher = toMatcher(matcher);

var idx = isArray(collection) ? -1 : undefined;
let idx = isArray(collection) ? -1 : undefined;

forEach(collection, function(val, key) {
if (matcher(val, key)) {
Expand Down Expand Up @@ -203,7 +203,7 @@ export function some(collection, matcher) {
*/
export function map(collection, fn) {

var result = [];
let result = [];

forEach(collection, function(val, key) {
result.push(fn(val, key));
Expand Down Expand Up @@ -262,9 +262,9 @@ export function groupBy(collection, extractor, grouped = {}) {
extractor = toExtractor(extractor);

forEach(collection, function(val) {
var discriminator = extractor(val) || '_';
let discriminator = extractor(val) || '_';

var group = grouped[discriminator];
let group = grouped[discriminator];

if (!group) {
group = grouped[discriminator] = [];
Expand All @@ -281,11 +281,11 @@ export function uniqueBy(extractor, ...collections) {

extractor = toExtractor(extractor);

var grouped = {};
let grouped = {};

forEach(collections, (c) => groupBy(c, extractor, grouped));

var result = map(grouped, function(val, key) {
let result = map(grouped, function(val, key) {
return val[0];
});

Expand All @@ -309,12 +309,12 @@ export function sortBy(collection, extractor) {

extractor = toExtractor(extractor);

var sorted = [];
let sorted = [];

forEach(collection, function(value, key) {
var disc = extractor(value, key);
let disc = extractor(value, key);

var entry = {
let entry = {
d: disc,
v: value
};
Expand Down Expand Up @@ -343,7 +343,7 @@ export function sortBy(collection, extractor) {
*
* const matcher = matchPattern({ id: 1 });
*
* var element = find(elements, matcher);
* let element = find(elements, matcher);
*
* @param {Object} pattern
*
Expand Down
13 changes: 6 additions & 7 deletions lib/fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
*/
export function debounce(fn, timeout) {

var timer;
let timer;

var lastArgs;
var lastThis;
let lastArgs;
let lastThis;

var lastNow;
let lastNow;

function fire() {

var now = Date.now();
let now = Date.now();

var scheduledDiff = (lastNow + timeout) - now;
let scheduledDiff = (lastNow + timeout) - now;

if (scheduledDiff > 0) {
return schedule(scheduledDiff);
Expand Down Expand Up @@ -60,7 +60,6 @@ export function debounce(fn, timeout) {
* @return {Function} throttled function
*/
export function throttle(fn, interval) {

let throttling = false;

return function(...args) {
Expand Down
2 changes: 1 addition & 1 deletion lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export function sortBy<T>(collection: Collection<T>, extractor: Extractor<T, num
*
* const matcher = matchPattern({ id: 1 });
*
* var element = find(elements, matcher);
* let element = find(elements, matcher);
*
* @param {Object} pattern
*
Expand Down
18 changes: 9 additions & 9 deletions lib/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ export function assign(target, ...others) {
*/
export function set(target, path, value) {

var currentTarget = target;
let currentTarget = target;

forEach(path, function(key, idx) {

if (key === '__proto__') {
throw new Error('illegal key: __proto__');
}

var nextKey = path[idx + 1];
var nextTarget = currentTarget[key];
let nextKey = path[idx + 1];
let nextTarget = currentTarget[key];

if (isDefined(nextKey) && isNil(nextTarget)) {
nextTarget = currentTarget[key] = isNaN(+nextKey) ? {} : [];
Expand Down Expand Up @@ -70,7 +70,7 @@ export function set(target, path, value) {
*/
export function get(target, path, defaultValue) {

var currentTarget = target;
let currentTarget = target;

forEach(path, function(key) {

Expand All @@ -97,9 +97,9 @@ export function get(target, path, defaultValue) {
*/
export function pick(target, properties) {

var result = {};
let result = {};

var obj = Object(target);
let obj = Object(target);

forEach(properties, function(prop) {

Expand All @@ -121,9 +121,9 @@ export function pick(target, properties) {
*/
export function omit(target, properties) {

var result = {};
let result = {};

var obj = Object(target);
let obj = Object(target);

forEach(obj, function(prop, key) {

Expand Down Expand Up @@ -164,7 +164,7 @@ export function merge(target, ...sources) {
return;
}

var targetVal = target[key];
let targetVal = target[key];

if (isObject(sourceVal)) {

Expand Down
2 changes: 1 addition & 1 deletion test/array.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('array', function() {
it('should flatten, one level deep', function() {

// given
var arr = [
let arr = [
[ 'A', 1 ],
[ 'B' ],
[ 'C', [ 1, 2, 3 ] ],
Expand Down
Loading

0 comments on commit 51443fe

Please sign in to comment.