@rjweb/utils
Advanced tools
Comparing version 1.4.3 to 1.4.4
@@ -0,1 +1,5 @@ | ||
## 1.4.4 | ||
- Add `array.rotate` | ||
## 1.4.3 | ||
@@ -2,0 +6,0 @@ |
@@ -22,2 +22,3 @@ "use strict"; | ||
remove: () => remove, | ||
rotate: () => rotate, | ||
sum: () => sum | ||
@@ -44,2 +45,9 @@ }); | ||
} | ||
function rotate(input, rotations) { | ||
const arr = Array.from(input); | ||
for (let i = 0; i < rotations; i++) { | ||
arr.push(arr.shift()); | ||
} | ||
return arr; | ||
} | ||
function sum(input) { | ||
@@ -51,3 +59,4 @@ return input.reduce((prev, current) => prev + current, 0); | ||
remove, | ||
rotate, | ||
sum | ||
}); |
{ | ||
"name": "@rjweb/utils", | ||
"version": "1.4.3", | ||
"version": "1.4.4", | ||
"description": "Easy and Lightweight Utilities", | ||
@@ -5,0 +5,0 @@ "module": "lib/esm/index.js", |
@@ -19,2 +19,9 @@ function remove(input, mode, value) { | ||
} | ||
function rotate(input, rotations) { | ||
const arr = Array.from(input); | ||
for (let i = 0; i < rotations; i++) { | ||
arr.push(arr.shift()); | ||
} | ||
return arr; | ||
} | ||
function sum(input) { | ||
@@ -25,3 +32,4 @@ return input.reduce((prev, current) => prev + current, 0); | ||
remove, | ||
rotate, | ||
sum | ||
}; |
{ | ||
"name": "@rjweb/utils", | ||
"version": "1.4.3", | ||
"version": "1.4.4", | ||
"description": "Easy and Lightweight Utilities", | ||
@@ -5,0 +5,0 @@ "module": "lib/esm/index.js", |
@@ -15,2 +15,15 @@ /** | ||
/** | ||
* Rotate an Array | ||
* @example | ||
* ``` | ||
* import { array } from "@rjweb/utils" | ||
* | ||
* const arr = ['A', 'B', 'C', 'D', 'E'] | ||
* | ||
* array.rotate(arr, 2) // ['C', 'D', 'E', 'A', 'B'] | ||
* array.rotate(arr, 4) // ['E', 'A', 'B', 'C', 'D'] | ||
* ``` | ||
* @since 1.4.4 | ||
*/ export declare function rotate<Arr extends any[]>(input: Arr, rotations: number): Arr; | ||
/** | ||
* Get the Sum of Numbers in an Array | ||
@@ -17,0 +30,0 @@ * @example |
{ | ||
"name": "@rjweb/utils", | ||
"version": "1.4.3", | ||
"version": "1.4.4", | ||
"description": "Easy and Lightweight Utilities", | ||
@@ -5,0 +5,0 @@ "module": "lib/esm/index.js", |
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
65819
1959