@ulu/utils
Advanced tools
Comparing version 0.0.13 to 0.0.15
# Change Log | ||
## 0.0.14 | ||
- (Added) Array > filterInPlace() Will not copy array, mutates the array passed (instead of copy [ie. Array.filter()]) | ||
## 0.0.13 | ||
- Browser > dom > isBrowser() Test whether script is executing in browser environment | ||
- (Added) Browser > dom > isBrowser() Test whether script is executing in browser environment | ||
## 0.0.12 | ||
- Array > getFirstLast() Test whether an index in an array is first or last | ||
- (Added) Array > getFirstLast() Test whether an index in an array is first or last | ||
## 0.0.11 | ||
- Array > joinForSentence (Used for joining array of strings/numbers for a sentence) | ||
- (Added) Array > joinForSentence (Used for joining array of strings/numbers for a sentence) | ||
- Example [1,2,3] "1, 2 and 3" | ||
@@ -18,13 +22,13 @@ | ||
- String > separateCssUnit (change returned value to number [versus string]) | ||
- (Added) String > separateCssUnit (change returned value to number [versus string]) | ||
## 0.0.9 | ||
- Add String (toInitials) Creates initials from string | ||
- (Added) Add String (toInitials) Creates initials from string | ||
## 0.0.8 | ||
- add number (sum and average) | ||
- Add array (removeDuplicates, createEmptyMatrix) | ||
- Add string (titleCase) | ||
- (Added) number (sum and average) | ||
- (Added) array (removeDuplicates, createEmptyMatrix) | ||
- (Added) string (titleCase) | ||
@@ -31,0 +35,0 @@ ## 0.0.7 |
@@ -121,2 +121,20 @@ /** | ||
}; | ||
} | ||
/** | ||
* Filter Array In Place | ||
* - Will not copy array, mutates the array passed (instead of copy [ie. Array.filter()]) | ||
* - Note, removes items in reverse order (end-to-start of array), test will be called on last item first and so on | ||
* @param {Array} array The array to filter items from | ||
* @param {Function} test A function to filter elements based on a truthy/falsy condition | ||
* @returns {Array} The original array | ||
*/ | ||
export function filterInPlace(array, test) { | ||
for (let i = array.length - 1; i >= 0; i--) { | ||
if (!test(array[i], i, array)) { | ||
array.splice(i, 1); | ||
} | ||
} | ||
return array; | ||
} |
{ | ||
"name": "@ulu/utils", | ||
"version": "0.0.13", | ||
"version": "0.0.15", | ||
"description": "Low level utility library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -67,2 +67,11 @@ /** | ||
export function getFirstLast(array: any[], index: number): any; | ||
/** | ||
* Filter Array In Place | ||
* - Will not copy array, mutates the array passed (instead of copy [ie. Array.filter()]) | ||
* - Note, removes items in reverse order (end-to-start of array), test will be called on last item first and so on | ||
* @param {Array} array The array to filter items from | ||
* @param {Function} test A function to filter elements based on a truthy/falsy condition | ||
* @returns {Array} The original array | ||
*/ | ||
export function filterInPlace(array: any[], test: Function): any[]; | ||
//# sourceMappingURL=array.d.ts.map |
Sorry, the diff of this file is not supported yet
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
42620
1104