cafe-utility 10.7.1 → 10.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +4 -0
- package/index.js +16 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -315,6 +315,8 @@ declare function tickPlaybook<T>(playbook: Playbook<T>): {
|
|
|
315
315
|
declare function getArgument(args: string[], key: string): string | null;
|
|
316
316
|
declare function requireStringArgument(args: string[], key: string): string;
|
|
317
317
|
declare function requireNumberArgument(args: string[], key: string): number;
|
|
318
|
+
declare function bringToFrontInPlace<T>(array: T[], index: number): void;
|
|
319
|
+
declare function bringToFront<T>(array: T[], index: number): T[];
|
|
318
320
|
declare type Point = {
|
|
319
321
|
x: number;
|
|
320
322
|
y: number;
|
|
@@ -381,6 +383,8 @@ export declare const Arrays: {
|
|
|
381
383
|
getArgument: typeof getArgument;
|
|
382
384
|
requireStringArgument: typeof requireStringArgument;
|
|
383
385
|
requireNumberArgument: typeof requireNumberArgument;
|
|
386
|
+
bringToFront: typeof bringToFront;
|
|
387
|
+
bringToFrontInPlace: typeof bringToFrontInPlace;
|
|
384
388
|
};
|
|
385
389
|
export declare const System: {
|
|
386
390
|
sleepMillis: typeof sleepMillis;
|
package/index.js
CHANGED
|
@@ -1601,6 +1601,7 @@ function fromObjectString(string) {
|
|
|
1601
1601
|
})
|
|
1602
1602
|
string = string.replace(/(,)(\s+})/g, '$2')
|
|
1603
1603
|
string = string.replace(/\.\.\..+?,/g, '')
|
|
1604
|
+
string = string.replace(/({\s+)([a-zA-Z]\w+),/g, "$1$2: '$2',")
|
|
1604
1605
|
string = string.replace(/(,\s+)([a-zA-Z]\w+),/g, "$1$2: '$2',")
|
|
1605
1606
|
string = string.replace(/:(.+)\?(.+):/g, (match, $1, $2) => {
|
|
1606
1607
|
return `: (${$1.trim()} && ${$2.trim()}) ||`
|
|
@@ -2150,6 +2151,18 @@ function requireNumberArgument(args, key) {
|
|
|
2150
2151
|
}
|
|
2151
2152
|
}
|
|
2152
2153
|
|
|
2154
|
+
function bringToFrontInPlace(array, index) {
|
|
2155
|
+
const item = array[index]
|
|
2156
|
+
array.splice(index, 1)
|
|
2157
|
+
array.unshift(item)
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
function bringToFront(array, index) {
|
|
2161
|
+
const newArray = [...array]
|
|
2162
|
+
bringToFrontInPlace(newArray, index)
|
|
2163
|
+
return newArray
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2153
2166
|
function addPoint(a, b) {
|
|
2154
2167
|
return {
|
|
2155
2168
|
x: a.x + b.x,
|
|
@@ -2480,7 +2493,9 @@ exports.Arrays = {
|
|
|
2480
2493
|
tickPlaybook,
|
|
2481
2494
|
getArgument,
|
|
2482
2495
|
requireStringArgument,
|
|
2483
|
-
requireNumberArgument
|
|
2496
|
+
requireNumberArgument,
|
|
2497
|
+
bringToFront,
|
|
2498
|
+
bringToFrontInPlace
|
|
2484
2499
|
}
|
|
2485
2500
|
|
|
2486
2501
|
exports.System = {
|