@aesthetic/utils
Advanced tools
Comparing version 0.4.1 to 0.4.2
import hash from 'string-hash'; | ||
function arrayLoop(array, callback) { | ||
function arrayLoop(array, callback, reverse) { | ||
if (reverse === void 0) { | ||
reverse = false; | ||
} | ||
var length = array.length; | ||
@@ -8,3 +12,4 @@ var i = 0; | ||
while (i < length) { | ||
callback(array[i], i); | ||
var x = reverse ? length - i - 1 : i; | ||
callback(array[x], x); | ||
i += 1; | ||
@@ -52,4 +57,2 @@ } | ||
function deepMerge() { | ||
var result = {}; | ||
for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) { | ||
@@ -59,2 +62,7 @@ objects[_key] = arguments[_key]; | ||
if (objects.length === 1) { | ||
return objects[0]; | ||
} | ||
var result = {}; | ||
arrayLoop(objects, function (object) { | ||
@@ -61,0 +69,0 @@ if (isObject(object)) { |
@@ -1,2 +0,2 @@ | ||
export default function arrayLoop<T extends unknown>(array: ArrayLike<T>, callback: (item: T, index: number) => void): void; | ||
export default function arrayLoop<T extends unknown>(array: ArrayLike<T>, callback: (item: T, index: number) => void, reverse?: boolean): void; | ||
//# sourceMappingURL=arrayLoop.d.ts.map |
@@ -11,3 +11,7 @@ 'use strict'; | ||
function arrayLoop(array, callback) { | ||
function arrayLoop(array, callback, reverse) { | ||
if (reverse === void 0) { | ||
reverse = false; | ||
} | ||
var length = array.length; | ||
@@ -17,3 +21,4 @@ var i = 0; | ||
while (i < length) { | ||
callback(array[i], i); | ||
var x = reverse ? length - i - 1 : i; | ||
callback(array[x], x); | ||
i += 1; | ||
@@ -61,4 +66,2 @@ } | ||
function deepMerge() { | ||
var result = {}; | ||
for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) { | ||
@@ -68,2 +71,7 @@ objects[_key] = arguments[_key]; | ||
if (objects.length === 1) { | ||
return objects[0]; | ||
} | ||
var result = {}; | ||
arrayLoop(objects, function (object) { | ||
@@ -70,0 +78,0 @@ if (isObject(object)) { |
{ | ||
"name": "@aesthetic/utils", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Utility functions for Aesthetic.", | ||
@@ -26,3 +26,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "67700b2a4307e451ddb61b3f7ca631080174838f" | ||
"gitHead": "cfd88a991530d5f6eccebb751049529486d41623" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
15331
282