@aidc-toolkit/utility 0.9.15-beta → 0.9.16-beta
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/dist/character-set.js +559 -0
- package/dist/character-set.js.map +1 -0
- package/dist/index.js +7 -1288
- package/dist/index.js.map +1 -0
- package/dist/locale/en/locale-strings.js +33 -0
- package/dist/locale/en/locale-strings.js.map +1 -0
- package/dist/locale/fr/locale-strings.js +33 -0
- package/dist/locale/fr/locale-strings.js.map +1 -0
- package/dist/locale/i18n.js +35 -0
- package/dist/locale/i18n.js.map +1 -0
- package/dist/record.js +55 -0
- package/dist/record.js.map +1 -0
- package/dist/reg-exp.js +55 -0
- package/dist/reg-exp.js.map +1 -0
- package/dist/sequence.js +96 -0
- package/dist/sequence.js.map +1 -0
- package/dist/string.js +2 -0
- package/dist/string.js.map +1 -0
- package/dist/transformer.js +483 -0
- package/dist/transformer.js.map +1 -0
- package/package.json +7 -7
- package/dist/index.cjs +0 -1358
- package/dist/index.d.cts +0 -909
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const localeStrings = {
|
|
2
|
+
Transformer: {
|
|
3
|
+
domainMustBeGreaterThanZero: "Domain {{domain}} must be greater than 0",
|
|
4
|
+
tweakMustBeGreaterThanOrEqualToZero: "Tweak {{tweak}} must be greater than or equal to 0",
|
|
5
|
+
valueMustBeGreaterThanOrEqualToZero: "Value {{value}} must be greater than or equal to 0",
|
|
6
|
+
valueMustBeLessThan: "Value {{value}} must be less than {{domain}}",
|
|
7
|
+
minimumValueMustBeGreaterThanOrEqualToZero: "Minimum value {{minimumValue}} must be greater than or equal to 0",
|
|
8
|
+
maximumValueMustBeLessThan: "Maximum value {{maximumValue}} must be less than {{domain}}"
|
|
9
|
+
},
|
|
10
|
+
RegExpValidator: {
|
|
11
|
+
stringDoesNotMatchPattern: "String {{s}} does not match pattern"
|
|
12
|
+
},
|
|
13
|
+
CharacterSetValidator: {
|
|
14
|
+
firstZeroFirstCharacter: "Character set must support zero as first character",
|
|
15
|
+
allNumericAllNumericCharacters: "Character set must support all numeric characters in sequence",
|
|
16
|
+
stringMustNotBeAllNumeric: "String must not be all numeric",
|
|
17
|
+
lengthMustBeGreaterThanOrEqualTo: "Length {{length}} must be greater than or equal to {{minimumLength}}",
|
|
18
|
+
lengthMustBeLessThanOrEqualTo: "Length {{length}} must be less than or equal to {{maximumLength}}",
|
|
19
|
+
lengthMustBeEqualTo: "Length {{length}} must be equal to {{exactLength}}",
|
|
20
|
+
lengthOfComponentMustBeGreaterThanOrEqualTo: "Length {{length}} of {{component}} must be greater than or equal to {{minimumLength}}",
|
|
21
|
+
lengthOfComponentMustBeLessThanOrEqualTo: "Length {{length}} of {{component}} must be less than or equal to {{maximumLength}}",
|
|
22
|
+
lengthOfComponentMustBeEqualTo: "Length {{length}} of {{component}} must be equal to {{exactLength}}",
|
|
23
|
+
invalidCharacterAtPosition: "Invalid character '{{c}}' at position {{position}}",
|
|
24
|
+
invalidCharacterAtPositionOfComponent: "Invalid character '{{c}}' at position {{position}} of {{component}}",
|
|
25
|
+
exclusionNotSupported: "Exclusion value of {{exclusion}} is not supported",
|
|
26
|
+
invalidTweakWithAllNumericExclusion: "Tweak must not be used with all-numeric exclusion",
|
|
27
|
+
endSequenceValueMustBeLessThanOrEqualTo: "End sequence value (start sequence value + count - 1) must be less than {{domain}}"
|
|
28
|
+
},
|
|
29
|
+
RecordValidator: {
|
|
30
|
+
typeNameKeyNotFound: "{{typeName}} \"{{key}}\" not found"
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=locale-strings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-strings.js","sourceRoot":"","sources":["../../../src/locale/en/locale-strings.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,WAAW,EAAE;QACT,2BAA2B,EAAE,0CAA0C;QACvE,mCAAmC,EAAE,oDAAoD;QACzF,mCAAmC,EAAE,oDAAoD;QACzF,mBAAmB,EAAE,8CAA8C;QACnE,0CAA0C,EAAE,mEAAmE;QAC/G,0BAA0B,EAAE,6DAA6D;KAC5F;IACD,eAAe,EAAE;QACb,yBAAyB,EAAE,qCAAqC;KACnE;IACD,qBAAqB,EAAE;QACnB,uBAAuB,EAAE,oDAAoD;QAC7E,8BAA8B,EAAE,+DAA+D;QAC/F,yBAAyB,EAAE,gCAAgC;QAC3D,gCAAgC,EAAE,sEAAsE;QACxG,6BAA6B,EAAE,mEAAmE;QAClG,mBAAmB,EAAE,oDAAoD;QACzE,2CAA2C,EAAE,uFAAuF;QACpI,wCAAwC,EAAE,oFAAoF;QAC9H,8BAA8B,EAAE,qEAAqE;QACrG,0BAA0B,EAAE,oDAAoD;QAChF,qCAAqC,EAAE,qEAAqE;QAC5G,qBAAqB,EAAE,mDAAmD;QAC1E,mCAAmC,EAAE,mDAAmD;QACxF,uCAAuC,EAAE,oFAAoF;KAChI;IACD,eAAe,EAAE;QACb,mBAAmB,EAAE,oCAAoC;KAC5D;CACK,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const localeStrings = {
|
|
2
|
+
Transformer: {
|
|
3
|
+
domainMustBeGreaterThanZero: "Le domaine {{domain}} doit être supérieur à 0",
|
|
4
|
+
tweakMustBeGreaterThanOrEqualToZero: "Le réglage {{tweak}} doit être supérieur ou égal à 0",
|
|
5
|
+
valueMustBeGreaterThanOrEqualToZero: "La valeur {{value}} doit être supérieure ou égale à 0",
|
|
6
|
+
valueMustBeLessThan: "La valeur {{value}} doit être inférieure à {{domain}}",
|
|
7
|
+
minimumValueMustBeGreaterThanOrEqualToZero: "La valeur minimale {{minimumValue}} doit être supérieure ou égale à 0",
|
|
8
|
+
maximumValueMustBeLessThan: "La valeur maximale {{maximumValue}} doit être inférieure à {{domain}}"
|
|
9
|
+
},
|
|
10
|
+
RegExpValidator: {
|
|
11
|
+
stringDoesNotMatchPattern: "La chaîne {{s}} ne correspond pas au modèle"
|
|
12
|
+
},
|
|
13
|
+
CharacterSetValidator: {
|
|
14
|
+
firstZeroFirstCharacter: "Le jeu de caractères doit prendre en charge zéro comme premier caractère",
|
|
15
|
+
allNumericAllNumericCharacters: "Le jeu de caractères doit prendre en charge tous les caractères numériques en séquence",
|
|
16
|
+
stringMustNotBeAllNumeric: "La chaîne ne doit pas être entièrement numérique",
|
|
17
|
+
lengthMustBeGreaterThanOrEqualTo: "La longueur {{length}} doit être supérieure ou égale à {{minimumLength}}",
|
|
18
|
+
lengthMustBeLessThanOrEqualTo: "La longueur {{length}} doit être inférieure ou égale à {{maximumLength}}",
|
|
19
|
+
lengthMustBeEqualTo: "La longueur {{length}} doit être égale à {{exactLength}}",
|
|
20
|
+
lengthOfComponentMustBeGreaterThanOrEqualTo: "La longueur {{length}} de {{component}} doit être supérieure ou égale à {{minimumLength}}",
|
|
21
|
+
lengthOfComponentMustBeLessThanOrEqualTo: "La longueur {{length}} de {{component}} doit être inférieure ou égale à {{maximumLength}}",
|
|
22
|
+
lengthOfComponentMustBeEqualTo: "La longueur {{length}} de {{component}} doit être égale à {{exactLength}}",
|
|
23
|
+
invalidCharacterAtPosition: "Caractère non valide '{{c}}' à la position {{position}}",
|
|
24
|
+
invalidCharacterAtPositionOfComponent: "Caractère non valide '{{c}}' à la position {{position}} de {{component}}",
|
|
25
|
+
exclusionNotSupported: "La valeur d'exclusion de {{exclusion}} n'est pas prise en charge",
|
|
26
|
+
invalidTweakWithAllNumericExclusion: "Le réglage ne doit pas être utilisé avec une exclusion entièrement numérique",
|
|
27
|
+
endSequenceValueMustBeLessThanOrEqualTo: "La valeur de la séquence de fin (valeur de la séquence de début + nombre - 1) doit être inférieure à {{domaine}}"
|
|
28
|
+
},
|
|
29
|
+
RecordValidator: {
|
|
30
|
+
typeNameKeyNotFound: "{{typeName}} \"{{key}}\" introuvable"
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=locale-strings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-strings.js","sourceRoot":"","sources":["../../../src/locale/fr/locale-strings.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,WAAW,EAAE;QACT,2BAA2B,EAAE,+CAA+C;QAC5E,mCAAmC,EAAE,sDAAsD;QAC3F,mCAAmC,EAAE,uDAAuD;QAC5F,mBAAmB,EAAE,uDAAuD;QAC5E,0CAA0C,EAAE,uEAAuE;QACnH,0BAA0B,EAAE,uEAAuE;KACtG;IACD,eAAe,EAAE;QACb,yBAAyB,EAAE,6CAA6C;KAC3E;IACD,qBAAqB,EAAE;QACnB,uBAAuB,EAAE,0EAA0E;QACnG,8BAA8B,EAAE,wFAAwF;QACxH,yBAAyB,EAAE,kDAAkD;QAC7E,gCAAgC,EAAE,0EAA0E;QAC5G,6BAA6B,EAAE,0EAA0E;QACzG,mBAAmB,EAAE,0DAA0D;QAC/E,2CAA2C,EAAE,2FAA2F;QACxI,wCAAwC,EAAE,2FAA2F;QACrI,8BAA8B,EAAE,2EAA2E;QAC3G,0BAA0B,EAAE,yDAAyD;QACrF,qCAAqC,EAAE,0EAA0E;QACjH,qBAAqB,EAAE,kEAAkE;QACzF,mCAAmC,EAAE,8EAA8E;QACnH,uCAAuC,EAAE,kHAAkH;KAC9J;IACD,eAAe,EAAE;QACb,mBAAmB,EAAE,sCAAsC;KAC9D;CACK,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { i18nAssertValidResources, i18nCoreInit } from "@aidc-toolkit/core";
|
|
2
|
+
import i18next from "i18next";
|
|
3
|
+
import { localeStrings as enLocaleStrings } from "./en/locale-strings.js";
|
|
4
|
+
import { localeStrings as frLocaleStrings } from "./fr/locale-strings.js";
|
|
5
|
+
export const utilityNS = "aidct_utility";
|
|
6
|
+
i18nAssertValidResources(enLocaleStrings, "fr", frLocaleStrings);
|
|
7
|
+
/**
|
|
8
|
+
* Utility resources.
|
|
9
|
+
*/
|
|
10
|
+
export const utilityResources = {
|
|
11
|
+
en: {
|
|
12
|
+
aidct_utility: enLocaleStrings
|
|
13
|
+
},
|
|
14
|
+
fr: {
|
|
15
|
+
aidct_utility: frLocaleStrings
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
// Explicit type is necessary to work around bug in type discovery with linked packages.
|
|
19
|
+
export const i18nextUtility = i18next.createInstance();
|
|
20
|
+
/**
|
|
21
|
+
* Initialize internationalization.
|
|
22
|
+
*
|
|
23
|
+
* @param environment
|
|
24
|
+
* Environment in which the application is running.
|
|
25
|
+
*
|
|
26
|
+
* @param debug
|
|
27
|
+
* Debug setting.
|
|
28
|
+
*
|
|
29
|
+
* @returns
|
|
30
|
+
* Void promise.
|
|
31
|
+
*/
|
|
32
|
+
export async function i18nUtilityInit(environment, debug = false) {
|
|
33
|
+
await i18nCoreInit(i18nextUtility, environment, debug, utilityNS, utilityResources);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=i18n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/locale/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAwB,MAAM,oBAAoB,CAAC;AAClG,OAAO,OAAqC,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,aAAa,IAAI,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE1E,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,CAAC;AAOzC,wBAAwB,CAAC,eAAe,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC;AAEjE;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAa;IACtC,EAAE,EAAE;QACA,aAAa,EAAE,eAAe;KACjC;IACD,EAAE,EAAE;QACA,aAAa,EAAE,eAAe;KACjC;CACJ,CAAC;AAEF,wFAAwF;AACxF,MAAM,CAAC,MAAM,cAAc,GAAS,OAAO,CAAC,cAAc,EAAE,CAAC;AAE7D;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,WAA4B,EAAE,KAAK,GAAG,KAAK;IAC7E,MAAM,YAAY,CAAC,cAAc,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC;AACxF,CAAC"}
|
package/dist/record.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { i18nextUtility } from "./locale/i18n.js";
|
|
2
|
+
/**
|
|
3
|
+
* Record validator. Validation is performed against a record with a string key type and throws an error if the key is
|
|
4
|
+
* not found.
|
|
5
|
+
*/
|
|
6
|
+
export class RecordValidator {
|
|
7
|
+
/**
|
|
8
|
+
* Type name for error message.
|
|
9
|
+
*/
|
|
10
|
+
_typeName;
|
|
11
|
+
/**
|
|
12
|
+
* Record in which to look up keys.
|
|
13
|
+
*/
|
|
14
|
+
_record;
|
|
15
|
+
/**
|
|
16
|
+
* Constructor.
|
|
17
|
+
*
|
|
18
|
+
* @param typeName
|
|
19
|
+
* Type name for error message.
|
|
20
|
+
*
|
|
21
|
+
* @param record
|
|
22
|
+
* Record in which to look up keys.
|
|
23
|
+
*/
|
|
24
|
+
constructor(typeName, record) {
|
|
25
|
+
this._typeName = typeName;
|
|
26
|
+
this._record = record;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get the type name.
|
|
30
|
+
*/
|
|
31
|
+
get typeName() {
|
|
32
|
+
return this._typeName;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get the record.
|
|
36
|
+
*/
|
|
37
|
+
get record() {
|
|
38
|
+
return this._record;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Validate a key by looking it up in the record.
|
|
42
|
+
*
|
|
43
|
+
* @param key
|
|
44
|
+
* Record key.
|
|
45
|
+
*/
|
|
46
|
+
validate(key) {
|
|
47
|
+
if (!(key in this.record)) {
|
|
48
|
+
throw new RangeError(i18nextUtility.t("RecordValidator.typeNameKeyNotFound", {
|
|
49
|
+
typeName: this.typeName,
|
|
50
|
+
key
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD;;;GAGG;AACH,MAAM,OAAO,eAAe;IACxB;;OAEG;IACc,SAAS,CAAS;IAEnC;;OAEG;IACc,OAAO,CAA8B;IAEtD;;;;;;;;OAQG;IACH,YAAY,QAAgB,EAAE,MAAmC;QAC7D,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACH,QAAQ,CAAC,GAAW;QAChB,IAAI,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,qCAAqC,EAAE;gBACzE,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,GAAG;aACN,CAAC,CAAC,CAAC;QACR,CAAC;IACL,CAAC;CACJ"}
|
package/dist/reg-exp.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { i18nextUtility } from "./locale/i18n.js";
|
|
2
|
+
/**
|
|
3
|
+
* Regular expression validator. The regular expression applies to the full string only if constructed as such. For
|
|
4
|
+
* example, <code>/\d*/</code> (0 or more digits) matches every string, <code>/\d+/</code>
|
|
5
|
+
* (1 or more digits) matches strings with at least one digit, <code>/^\d*$/</code> matches strings that
|
|
6
|
+
* are all digits or empty, and <code>/^\d+$/</code> matches strings that are all digits and not empty.
|
|
7
|
+
*
|
|
8
|
+
* Clients of this class are recommended to override the {@link createErrorMessage} method create a more suitable error
|
|
9
|
+
* message for their use case.
|
|
10
|
+
*/
|
|
11
|
+
export class RegExpValidator {
|
|
12
|
+
/**
|
|
13
|
+
* Regular expression.
|
|
14
|
+
*/
|
|
15
|
+
_regExp;
|
|
16
|
+
/**
|
|
17
|
+
* Constructor.
|
|
18
|
+
*
|
|
19
|
+
* @param regExp
|
|
20
|
+
* Regular expression. See {@link RegExpValidator | class documentation} for notes.
|
|
21
|
+
*/
|
|
22
|
+
constructor(regExp) {
|
|
23
|
+
this._regExp = regExp;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get the regular expression.
|
|
27
|
+
*/
|
|
28
|
+
get regExp() {
|
|
29
|
+
return this._regExp;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create an error message for a string. The generic error message is sufficient for many use cases but a more
|
|
33
|
+
* domain-specific error message, possibly including the pattern itself, is often required.
|
|
34
|
+
*
|
|
35
|
+
* @param s
|
|
36
|
+
* String.
|
|
37
|
+
*
|
|
38
|
+
* @returns
|
|
39
|
+
* Error message.
|
|
40
|
+
*/
|
|
41
|
+
createErrorMessage(s) {
|
|
42
|
+
return i18nextUtility.t("RegExpValidator.stringDoesNotMatchPattern", {
|
|
43
|
+
s
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @inheritDoc
|
|
48
|
+
*/
|
|
49
|
+
validate(s) {
|
|
50
|
+
if (!this._regExp.test(s)) {
|
|
51
|
+
throw new RangeError(this.createErrorMessage(s));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=reg-exp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reg-exp.js","sourceRoot":"","sources":["../src/reg-exp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD;;;;;;;;GAQG;AACH,MAAM,OAAO,eAAe;IACxB;;OAEG;IACc,OAAO,CAAS;IAEjC;;;;;OAKG;IACH,YAAY,MAAc;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;;;;;;;;OASG;IACO,kBAAkB,CAAC,CAAS;QAClC,OAAO,cAAc,CAAC,CAAC,CAAC,2CAA2C,EAAE;YACjE,CAAC;SACJ,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,CAAS;QACd,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;QACrD,CAAC;IACL,CAAC;CACJ"}
|
package/dist/sequence.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sequence. Defines an ascending or descending sequence of big integers implemented as an iterable.
|
|
3
|
+
*/
|
|
4
|
+
export class Sequence {
|
|
5
|
+
/**
|
|
6
|
+
* Start value (inclusive).
|
|
7
|
+
*/
|
|
8
|
+
_startValue;
|
|
9
|
+
/**
|
|
10
|
+
* End value (exclusive).
|
|
11
|
+
*/
|
|
12
|
+
_endValue;
|
|
13
|
+
/**
|
|
14
|
+
* Count of values.
|
|
15
|
+
*/
|
|
16
|
+
_count;
|
|
17
|
+
/**
|
|
18
|
+
* Delta to the next value; equal to the sign of the count.
|
|
19
|
+
*/
|
|
20
|
+
_nextDelta;
|
|
21
|
+
/**
|
|
22
|
+
* Minimum value (inclusive).
|
|
23
|
+
*/
|
|
24
|
+
_minimumValue;
|
|
25
|
+
/**
|
|
26
|
+
* Maximum value (inclusive).
|
|
27
|
+
*/
|
|
28
|
+
_maximumValue;
|
|
29
|
+
/**
|
|
30
|
+
* Constructor.
|
|
31
|
+
*
|
|
32
|
+
* @param startValue
|
|
33
|
+
* Start value.
|
|
34
|
+
*
|
|
35
|
+
* @param count
|
|
36
|
+
* Count of values. If count is zero or positive, iteration ascends from start value, otherwise it descends from
|
|
37
|
+
* start value.
|
|
38
|
+
*/
|
|
39
|
+
constructor(startValue, count) {
|
|
40
|
+
this._startValue = BigInt(startValue);
|
|
41
|
+
this._endValue = this._startValue + BigInt(count);
|
|
42
|
+
this._count = count;
|
|
43
|
+
if (count >= 0) {
|
|
44
|
+
this._nextDelta = 1n;
|
|
45
|
+
this._minimumValue = this._startValue;
|
|
46
|
+
this._maximumValue = this._endValue - 1n;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this._nextDelta = -1n;
|
|
50
|
+
this._minimumValue = this._endValue + 1n;
|
|
51
|
+
this._maximumValue = this._startValue;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get the start value (inclusive).
|
|
56
|
+
*/
|
|
57
|
+
get startValue() {
|
|
58
|
+
return this._startValue;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get the end value (exclusive).
|
|
62
|
+
*/
|
|
63
|
+
get endValue() {
|
|
64
|
+
return this._endValue;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get the count of values.
|
|
68
|
+
*/
|
|
69
|
+
get count() {
|
|
70
|
+
return this._count;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get the minimum value (inclusive).
|
|
74
|
+
*/
|
|
75
|
+
get minimumValue() {
|
|
76
|
+
return this._minimumValue;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get the maximum value (inclusive).
|
|
80
|
+
*/
|
|
81
|
+
get maximumValue() {
|
|
82
|
+
return this._maximumValue;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Iterable implementation.
|
|
86
|
+
*
|
|
87
|
+
* @yields
|
|
88
|
+
* Next value in sequence.
|
|
89
|
+
*/
|
|
90
|
+
*[Symbol.iterator]() {
|
|
91
|
+
for (let value = this._startValue; value !== this._endValue; value += this._nextDelta) {
|
|
92
|
+
yield value;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=sequence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequence.js","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,QAAQ;IACjB;;OAEG;IACc,WAAW,CAAS;IAErC;;OAEG;IACc,SAAS,CAAS;IAEnC;;OAEG;IACc,MAAM,CAAS;IAEhC;;OAEG;IACc,UAAU,CAAW;IAEtC;;OAEG;IACc,aAAa,CAAS;IAEvC;;OAEG;IACc,aAAa,CAAS;IAEvC;;;;;;;;;OASG;IACH,YAAY,UAA2B,EAAE,KAAa;QAClD,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAClD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QAEpB,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YACb,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;YACrB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC;YACtC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QAC7C,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;YACzC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC;QAC1C,CAAC;IACL,CAAC;IAED;;OAEG;IACH,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,CAAE,CAAC,MAAM,CAAC,QAAQ,CAAC;QACf,KAAK,IAAI,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,KAAK,KAAK,IAAI,CAAC,SAAS,EAAE,KAAK,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpF,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;CACJ"}
|
package/dist/string.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.js","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":""}
|