Comparing version 1.6.0 to 1.7.0
@@ -676,2 +676,10 @@ declare type Partial$1<T> = { | ||
declare const entries: <T>(arr: T[]) => [number, T][]; | ||
/** | ||
* Returns an array with the given items repeated | ||
* | ||
* ```typescript | ||
* repeat(5, 'a', 'b'); // 'a', 'b', 'a', 'b', 'a' | ||
* ``` | ||
*/ | ||
declare const repeat: <T>(maxLength: number, ...items: T[]) => T[]; | ||
@@ -684,2 +692,3 @@ declare const ArrayUtils_range: typeof range; | ||
declare const ArrayUtils_entries: typeof entries; | ||
declare const ArrayUtils_repeat: typeof repeat; | ||
declare namespace ArrayUtils { | ||
@@ -693,5 +702,6 @@ export { | ||
ArrayUtils_entries as entries, | ||
ArrayUtils_repeat as repeat, | ||
}; | ||
} | ||
export { ArrayUtils, CENTURY, CustomEntryDict, DAY, DECADE, DeferredPromise, HOUR, KeysOnly, MILLENNIUM, MILLISECOND, MINUTE, MONTH, Numbered, Partial$1 as Partial, ProgressBarOptions, PromiseUtils, SECOND, WEEK, YEAR, all, allLimit, allLimitObj, allObj, centuries, century, day, days, decade, decades, each, eachLimit, entries, getDeferred, getProgressBar, getTimer, hour, hours, interval, map, mapLimit, millennium, millenniums, milliseconds, minute, minutes, month, months, ms, printLn, progressBar, randomise, range, reverse, second, seconds, sortByMapped, stopInterval, timer, times, wait, waitEvery, waitFor, waitUntil, waiters, week, weeks, year, years, zip }; | ||
export { ArrayUtils, CENTURY, CustomEntryDict, DAY, DECADE, DeferredPromise, HOUR, KeysOnly, MILLENNIUM, MILLISECOND, MINUTE, MONTH, Numbered, Partial$1 as Partial, ProgressBarOptions, PromiseUtils, SECOND, WEEK, YEAR, all, allLimit, allLimitObj, allObj, centuries, century, day, days, decade, decades, each, eachLimit, entries, getDeferred, getProgressBar, getTimer, hour, hours, interval, map, mapLimit, millennium, millenniums, milliseconds, minute, minutes, month, months, ms, printLn, progressBar, randomise, range, repeat, reverse, second, seconds, sortByMapped, stopInterval, timer, times, wait, waitEvery, waitFor, waitUntil, waiters, week, weeks, year, years, zip }; |
@@ -60,2 +60,3 @@ var __defProp = Object.defineProperty; | ||
range: () => range, | ||
repeat: () => repeat, | ||
reverse: () => reverse, | ||
@@ -500,2 +501,3 @@ seconds: () => seconds, | ||
range: () => range, | ||
repeat: () => repeat, | ||
reverse: () => reverse, | ||
@@ -514,2 +516,6 @@ sortByMapped: () => sortByMapped, | ||
var entries = (arr) => zip(range(arr.length), arr); | ||
var repeat = (maxLength, ...items) => { | ||
const simple = new Array(maxLength).fill(items[0]); | ||
return items.length === 1 ? simple : simple.map((v, i) => items[i % items.length]); | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -555,2 +561,3 @@ 0 && (module.exports = { | ||
range, | ||
repeat, | ||
reverse, | ||
@@ -557,0 +564,0 @@ seconds, |
{ | ||
"name": "swiss-ak", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"author": "Jack Cannon <jackc@annon.co.uk> (http://c.annon.co.uk/)", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -234,2 +234,10 @@ # swiss-ak (Swiss Army Knife) | ||
### repeat | ||
Returns an array with the given items repeated | ||
```typescript | ||
repeat(5, 'a', 'b'); // 'a', 'b', 'a', 'b', 'a' | ||
``` | ||
## PromiseUtils | ||
@@ -236,0 +244,0 @@ |
@@ -98,1 +98,13 @@ /** | ||
export const entries = <T>(arr: T[]): [number, T][] => zip(range(arr.length), arr) as any; | ||
/** | ||
* Returns an array with the given items repeated | ||
* | ||
* ```typescript | ||
* repeat(5, 'a', 'b'); // 'a', 'b', 'a', 'b', 'a' | ||
* ``` | ||
*/ | ||
export const repeat = <T>(maxLength: number, ...items: T[]): T[] => { | ||
const simple = new Array(maxLength).fill(items[0]); | ||
return items.length === 1 ? simple : simple.map((v, i) => items[i % items.length]); | ||
}; |
Sorry, the diff of this file is not supported yet
98499
2915
532