cafe-utility 6.2.0 → 6.2.1
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 +1 -1
- package/index.js +5 -5
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -211,7 +211,7 @@ declare function increment(value: number, change: number, maximum: number): numb
|
|
|
211
211
|
declare function decrement(value: number, change: number, minimum: number): number;
|
|
212
212
|
declare function runOn<T>(object: T, callable: (object: T) => void): T;
|
|
213
213
|
declare function ifPresent<T>(object: T, callable: (object: T) => void): void;
|
|
214
|
-
declare function mergeArrays(target: CafeObject<unknown[]>, source: CafeObject<unknown[]>): void;
|
|
214
|
+
declare function mergeArrays(target: CafeObject<unknown | unknown[]>, source: CafeObject<unknown | unknown[]>): void;
|
|
215
215
|
declare function empty<T>(array: T[]): T[];
|
|
216
216
|
declare function removeEmptyArrays(object: CafeObject): CafeObject;
|
|
217
217
|
declare function removeEmptyValues(object: CafeObject): CafeObject;
|
package/index.js
CHANGED
|
@@ -885,11 +885,11 @@ function csvEscape(string) {
|
|
|
885
885
|
function findWeightedPair(string, start = 0, opening = '{', closing = '}') {
|
|
886
886
|
let weight = 1
|
|
887
887
|
for (let i = start; i < string.length; i++) {
|
|
888
|
-
if (string
|
|
888
|
+
if (string.slice(i, i + closing.length) === closing) {
|
|
889
889
|
if (--weight === 0) {
|
|
890
890
|
return i
|
|
891
891
|
}
|
|
892
|
-
} else if (string
|
|
892
|
+
} else if (string.slice(i, i + opening.length) === opening) {
|
|
893
893
|
weight++
|
|
894
894
|
}
|
|
895
895
|
}
|
|
@@ -901,12 +901,12 @@ function extractBlock(string, options) {
|
|
|
901
901
|
if (opensAt === -1) {
|
|
902
902
|
return null
|
|
903
903
|
}
|
|
904
|
-
const closesAt = findWeightedPair(string, opensAt +
|
|
904
|
+
const closesAt = findWeightedPair(string, opensAt + options.opening.length, options.opening, options.closing)
|
|
905
905
|
return closesAt === -1
|
|
906
906
|
? null
|
|
907
907
|
: options.exclusive
|
|
908
|
-
? string.slice(opensAt +
|
|
909
|
-
: string.slice(opensAt, closesAt +
|
|
908
|
+
? string.slice(opensAt + options.opening.length, closesAt)
|
|
909
|
+
: string.slice(opensAt, closesAt + options.closing.length)
|
|
910
910
|
}
|
|
911
911
|
|
|
912
912
|
function extractAllBlocks(string, options) {
|