isaacscript-common 69.2.0 → 69.3.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.
@@ -14650,6 +14650,18 @@ export declare function parseEntityID(entityID: string): [entityType: EntityType
14650
14650
  */
14651
14651
  export declare function parseEntityTypeVariantString(entityTypeVariantString: string): [entityType: EntityType, variant: int] | undefined;
14652
14652
 
14653
+ /**
14654
+ * Helper function to parse a Semantic Versioning string into its individual constituents. Returns
14655
+ * undefined if the submitted string was not a proper Semantic Version string.
14656
+ *
14657
+ * https://semver.org/
14658
+ */
14659
+ export declare function parseSemanticVersion(versionString: string): {
14660
+ majorVersion: int;
14661
+ minorVersion: int;
14662
+ patchVersion: int;
14663
+ } | undefined;
14664
+
14653
14665
  declare class Pause extends Feature {
14654
14666
  private readonly disableInputs;
14655
14667
  private readonly postUpdate;
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 69.2.0
3
+ isaacscript-common 69.3.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -16502,6 +16502,19 @@ function ____exports.getObjectPartialMatch(self, searchText, object)
16502
16502
  assertDefined(nil, value, "Failed to get the object value corresponding to the partial match of: " .. matchingKey)
16503
16503
  return {matchingKey, value}
16504
16504
  end
16505
+ function ____exports.parseSemanticVersion(self, versionString)
16506
+ local majorVersionString, minorVersionString, patchVersionString = string.match(versionString, "(%d+).(%d+).(%d+)")
16507
+ if majorVersionString == nil or minorVersionString == nil or patchVersionString == nil then
16508
+ return nil
16509
+ end
16510
+ local majorVersion = tonumber(majorVersionString)
16511
+ local minorVersion = tonumber(minorVersionString)
16512
+ local patchVersion = tonumber(patchVersionString)
16513
+ if majorVersion == nil or minorVersion == nil or patchVersion == nil then
16514
+ return nil
16515
+ end
16516
+ return {majorVersion = majorVersion, minorVersion = minorVersion, patchVersion = patchVersion}
16517
+ end
16505
16518
  function ____exports.removeAllCharacters(self, ____string, character)
16506
16519
  return __TS__StringReplaceAll(____string, character, "")
16507
16520
  end
@@ -1,3 +1,4 @@
1
+ /// <reference types="isaac-typescript-definitions" />
1
2
  export declare function capitalizeFirstLetter(string: string): string;
2
3
  /**
3
4
  * Helper function to get the closest key from a map based on partial search text. (It only searches
@@ -67,6 +68,17 @@ export declare function getObjectPartialMatch<T>(searchText: string, object: Rec
67
68
  * ```
68
69
  */
69
70
  export declare function getPartialMatch(searchText: string, array: string[]): string | undefined;
71
+ /**
72
+ * Helper function to parse a Semantic Versioning string into its individual constituents. Returns
73
+ * undefined if the submitted string was not a proper Semantic Version string.
74
+ *
75
+ * https://semver.org/
76
+ */
77
+ export declare function parseSemanticVersion(versionString: string): {
78
+ majorVersion: int;
79
+ minorVersion: int;
80
+ patchVersion: int;
81
+ } | undefined;
70
82
  export declare function removeAllCharacters(string: string, character: string): string;
71
83
  /**
72
84
  * Helper function to remove all of the characters in a string before a given substring. Returns the
@@ -1 +1 @@
1
- {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../src/functions/string.ts"],"names":[],"mappings":"AAEA,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,EA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C7B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EAAE,GACd,MAAM,GAAG,SAAS,CAYpB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GACtD;IACE,YAAY,EAAE,GAAG,CAAC;IAClB,YAAY,EAAE,GAAG,CAAC;IAClB,YAAY,EAAE,GAAG,CAAC;CACnB,GACD,SAAS,CAyBZ;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,MAAM,CAGR;AAED,8FAA8F;AAC9F,wBAAgB,+BAA+B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGnE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,GAAG,UAAU,EAAE,MAAM,EAAE,GACtB,MAAM,CAMR;AAED,gGAAgG;AAChG,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMjE;AAED,gGAAgG;AAChG,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOjE"}
@@ -112,6 +112,23 @@ function ____exports.getObjectPartialMatch(self, searchText, object)
112
112
  assertDefined(nil, value, "Failed to get the object value corresponding to the partial match of: " .. matchingKey)
113
113
  return {matchingKey, value}
114
114
  end
115
+ --- Helper function to parse a Semantic Versioning string into its individual constituents. Returns
116
+ -- undefined if the submitted string was not a proper Semantic Version string.
117
+ --
118
+ -- https://semver.org/
119
+ function ____exports.parseSemanticVersion(self, versionString)
120
+ local majorVersionString, minorVersionString, patchVersionString = string.match(versionString, "(%d+).(%d+).(%d+)")
121
+ if majorVersionString == nil or minorVersionString == nil or patchVersionString == nil then
122
+ return nil
123
+ end
124
+ local majorVersion = tonumber(majorVersionString)
125
+ local minorVersion = tonumber(minorVersionString)
126
+ local patchVersion = tonumber(patchVersionString)
127
+ if majorVersion == nil or minorVersion == nil or patchVersion == nil then
128
+ return nil
129
+ end
130
+ return {majorVersion = majorVersion, minorVersion = minorVersion, patchVersion = patchVersion}
131
+ end
115
132
  function ____exports.removeAllCharacters(self, ____string, character)
116
133
  return __TS__StringReplaceAll(____string, character, "")
117
134
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "69.2.0",
3
+ "version": "69.3.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -134,6 +134,45 @@ export function getPartialMatch(
134
134
  return matchingElements[0];
135
135
  }
136
136
 
137
+ /**
138
+ * Helper function to parse a Semantic Versioning string into its individual constituents. Returns
139
+ * undefined if the submitted string was not a proper Semantic Version string.
140
+ *
141
+ * https://semver.org/
142
+ */
143
+ export function parseSemanticVersion(versionString: string):
144
+ | {
145
+ majorVersion: int;
146
+ minorVersion: int;
147
+ patchVersion: int;
148
+ }
149
+ | undefined {
150
+ const [majorVersionString, minorVersionString, patchVersionString] =
151
+ string.match(versionString, "(%d+).(%d+).(%d+)");
152
+
153
+ if (
154
+ majorVersionString === undefined ||
155
+ minorVersionString === undefined ||
156
+ patchVersionString === undefined
157
+ ) {
158
+ return undefined;
159
+ }
160
+
161
+ const majorVersion = tonumber(majorVersionString);
162
+ const minorVersion = tonumber(minorVersionString);
163
+ const patchVersion = tonumber(patchVersionString);
164
+
165
+ if (
166
+ majorVersion === undefined ||
167
+ minorVersion === undefined ||
168
+ patchVersion === undefined
169
+ ) {
170
+ return undefined;
171
+ }
172
+
173
+ return { majorVersion, minorVersion, patchVersion };
174
+ }
175
+
137
176
  export function removeAllCharacters(string: string, character: string): string {
138
177
  return string.replaceAll(character, "");
139
178
  }