isaacscript-common 81.0.0 → 81.0.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.
|
@@ -67,7 +67,7 @@ export declare function getObjectPartialMatch<T>(searchText: string, object: Rec
|
|
|
67
67
|
* found, returns undefined.
|
|
68
68
|
* ```
|
|
69
69
|
*/
|
|
70
|
-
export declare function getPartialMatch(searchText: string, array: string[]): string | undefined;
|
|
70
|
+
export declare function getPartialMatch(searchText: string, array: string[] | readonly string[]): string | undefined;
|
|
71
71
|
/**
|
|
72
72
|
* Helper function to parse a Semantic Versioning string into its individual constituents. Returns
|
|
73
73
|
* undefined if the submitted string was not a proper Semantic Version string.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/functions/string.ts"],"names":[],"mappings":";AAGA,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAU5D;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,GAC1B,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAezB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GACxB,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAezB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/functions/string.ts"],"names":[],"mappings":";AAGA,wBAAgB,qBAAqB,CAAC,MAAM,E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M,EAAE,MAAM,GAAG,MAAM,CAMjE;AAED,gGAAgG;AAChG,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOjE;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAU9D"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__Spread = ____lualib.__TS__Spread
|
|
3
3
|
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
|
|
4
|
-
local
|
|
4
|
+
local __TS__ArrayToSorted = ____lualib.__TS__ArrayToSorted
|
|
5
5
|
local __TS__StringReplaceAll = ____lualib.__TS__StringReplaceAll
|
|
6
6
|
local __TS__StringStartsWith = ____lualib.__TS__StringStartsWith
|
|
7
7
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
8
|
+
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
8
9
|
local __TS__StringSlice = ____lualib.__TS__StringSlice
|
|
9
10
|
local __TS__StringEndsWith = ____lualib.__TS__StringEndsWith
|
|
10
11
|
local ____exports = {}
|
|
@@ -30,11 +31,11 @@ local assertDefined = ____utils.assertDefined
|
|
|
30
31
|
-- found, returns undefined.
|
|
31
32
|
-- ```
|
|
32
33
|
function ____exports.getPartialMatch(self, searchText, array)
|
|
33
|
-
|
|
34
|
+
local sortedArray = __TS__ArrayToSorted(array)
|
|
34
35
|
searchText = string.lower(searchText)
|
|
35
36
|
searchText = __TS__StringReplaceAll(searchText, " ", "")
|
|
36
37
|
local matchingElements = __TS__ArrayFilter(
|
|
37
|
-
|
|
38
|
+
sortedArray,
|
|
38
39
|
function(____, element) return __TS__StringStartsWith(
|
|
39
40
|
string.lower(element),
|
|
40
41
|
searchText
|
package/dist/index.rollup.d.ts
CHANGED
|
@@ -6590,7 +6590,7 @@ export declare function getParentFunctionDescription(this: void, levels?: number
|
|
|
6590
6590
|
* found, returns undefined.
|
|
6591
6591
|
* ```
|
|
6592
6592
|
*/
|
|
6593
|
-
export declare function getPartialMatch(searchText: string, array: string[]): string | undefined;
|
|
6593
|
+
export declare function getPartialMatch(searchText: string, array: string[] | readonly string[]): string | undefined;
|
|
6594
6594
|
|
|
6595
6595
|
/**
|
|
6596
6596
|
* Helper function to get the associated pill effect after PHD is acquired. If a pill effect is not
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common
|
|
3
|
+
isaacscript-common 81.0.0
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -17951,10 +17951,11 @@ return ____exports
|
|
|
17951
17951
|
local ____lualib = require("lualib_bundle")
|
|
17952
17952
|
local __TS__Spread = ____lualib.__TS__Spread
|
|
17953
17953
|
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
|
|
17954
|
-
local
|
|
17954
|
+
local __TS__ArrayToSorted = ____lualib.__TS__ArrayToSorted
|
|
17955
17955
|
local __TS__StringReplaceAll = ____lualib.__TS__StringReplaceAll
|
|
17956
17956
|
local __TS__StringStartsWith = ____lualib.__TS__StringStartsWith
|
|
17957
17957
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
17958
|
+
local __TS__ArraySort = ____lualib.__TS__ArraySort
|
|
17958
17959
|
local __TS__StringSlice = ____lualib.__TS__StringSlice
|
|
17959
17960
|
local __TS__StringEndsWith = ____lualib.__TS__StringEndsWith
|
|
17960
17961
|
local ____exports = {}
|
|
@@ -17980,11 +17981,11 @@ local assertDefined = ____utils.assertDefined
|
|
|
17980
17981
|
-- found, returns undefined.
|
|
17981
17982
|
-- ```
|
|
17982
17983
|
function ____exports.getPartialMatch(self, searchText, array)
|
|
17983
|
-
|
|
17984
|
+
local sortedArray = __TS__ArrayToSorted(array)
|
|
17984
17985
|
searchText = string.lower(searchText)
|
|
17985
17986
|
searchText = __TS__StringReplaceAll(searchText, " ", "")
|
|
17986
17987
|
local matchingElements = __TS__ArrayFilter(
|
|
17987
|
-
|
|
17988
|
+
sortedArray,
|
|
17988
17989
|
function(____, element) return __TS__StringStartsWith(
|
|
17989
17990
|
string.lower(element),
|
|
17990
17991
|
searchText
|
package/package.json
CHANGED
package/src/functions/string.ts
CHANGED
|
@@ -120,14 +120,14 @@ export function getObjectPartialMatch<T>(
|
|
|
120
120
|
*/
|
|
121
121
|
export function getPartialMatch(
|
|
122
122
|
searchText: string,
|
|
123
|
-
array: string[],
|
|
123
|
+
array: string[] | readonly string[],
|
|
124
124
|
): string | undefined {
|
|
125
|
-
array.
|
|
125
|
+
const sortedArray = array.toSorted();
|
|
126
126
|
|
|
127
127
|
searchText = searchText.toLowerCase();
|
|
128
128
|
searchText = searchText.replaceAll(" ", "");
|
|
129
129
|
|
|
130
|
-
const matchingElements =
|
|
130
|
+
const matchingElements = sortedArray.filter((element) =>
|
|
131
131
|
element.toLowerCase().startsWith(searchText),
|
|
132
132
|
);
|
|
133
133
|
matchingElements.sort();
|