@svta/cml-structured-field-values 0.19.0 → 0.21.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/README.md +25 -0
- package/dist/index.d.ts +391 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +710 -13
- package/dist/index.js.map +1 -1
- package/package.json +4 -23
- package/NOTICE +0 -36
- package/dist/SfBareItem.d.ts +0 -9
- package/dist/SfBareItem.d.ts.map +0 -1
- package/dist/SfBareItem.js +0 -2
- package/dist/SfBareItem.js.map +0 -1
- package/dist/SfDecodeOptions.d.ts +0 -13
- package/dist/SfDecodeOptions.d.ts.map +0 -1
- package/dist/SfDecodeOptions.js +0 -2
- package/dist/SfDecodeOptions.js.map +0 -1
- package/dist/SfDictionary.d.ts +0 -9
- package/dist/SfDictionary.d.ts.map +0 -1
- package/dist/SfDictionary.js +0 -2
- package/dist/SfDictionary.js.map +0 -1
- package/dist/SfEncodeOptions.d.ts +0 -13
- package/dist/SfEncodeOptions.d.ts.map +0 -1
- package/dist/SfEncodeOptions.js +0 -2
- package/dist/SfEncodeOptions.js.map +0 -1
- package/dist/SfInnerList.d.ts +0 -14
- package/dist/SfInnerList.d.ts.map +0 -1
- package/dist/SfInnerList.js +0 -2
- package/dist/SfInnerList.js.map +0 -1
- package/dist/SfItem.d.ts +0 -14
- package/dist/SfItem.d.ts.map +0 -1
- package/dist/SfItem.js +0 -16
- package/dist/SfItem.js.map +0 -1
- package/dist/SfMember.d.ts +0 -11
- package/dist/SfMember.d.ts.map +0 -1
- package/dist/SfMember.js +0 -2
- package/dist/SfMember.js.map +0 -1
- package/dist/SfParameters.d.ts +0 -8
- package/dist/SfParameters.d.ts.map +0 -1
- package/dist/SfParameters.js +0 -2
- package/dist/SfParameters.js.map +0 -1
- package/dist/SfToken.d.ts +0 -11
- package/dist/SfToken.d.ts.map +0 -1
- package/dist/SfToken.js +0 -12
- package/dist/SfToken.js.map +0 -1
- package/dist/decodeSfDict.d.ts +0 -13
- package/dist/decodeSfDict.d.ts.map +0 -1
- package/dist/decodeSfDict.js +0 -25
- package/dist/decodeSfDict.js.map +0 -1
- package/dist/decodeSfItem.d.ts +0 -13
- package/dist/decodeSfItem.d.ts.map +0 -1
- package/dist/decodeSfItem.js +0 -46
- package/dist/decodeSfItem.js.map +0 -1
- package/dist/decodeSfList.d.ts +0 -13
- package/dist/decodeSfList.d.ts.map +0 -1
- package/dist/decodeSfList.js +0 -25
- package/dist/decodeSfList.js.map +0 -1
- package/dist/encodeSfDict.d.ts +0 -14
- package/dist/encodeSfDict.d.ts.map +0 -1
- package/dist/encodeSfDict.js +0 -16
- package/dist/encodeSfDict.js.map +0 -1
- package/dist/encodeSfItem.d.ts +0 -26
- package/dist/encodeSfItem.d.ts.map +0 -1
- package/dist/encodeSfItem.js +0 -9
- package/dist/encodeSfItem.js.map +0 -1
- package/dist/encodeSfList.d.ts +0 -15
- package/dist/encodeSfList.d.ts.map +0 -1
- package/dist/encodeSfList.js +0 -16
- package/dist/encodeSfList.js.map +0 -1
- package/dist/parse/ParsedValue.d.ts +0 -6
- package/dist/parse/ParsedValue.d.ts.map +0 -1
- package/dist/parse/ParsedValue.js +0 -4
- package/dist/parse/ParsedValue.js.map +0 -1
- package/dist/parse/index.d.ts +0 -22
- package/dist/parse/index.d.ts.map +0 -1
- package/dist/parse/index.js +0 -21
- package/dist/parse/index.js.map +0 -1
- package/dist/parse/parseBareItem.d.ts +0 -5
- package/dist/parse/parseBareItem.d.ts.map +0 -1
- package/dist/parse/parseBareItem.js +0 -59
- package/dist/parse/parseBareItem.js.map +0 -1
- package/dist/parse/parseBoolean.d.ts +0 -3
- package/dist/parse/parseBoolean.d.ts.map +0 -1
- package/dist/parse/parseBoolean.js +0 -34
- package/dist/parse/parseBoolean.js.map +0 -1
- package/dist/parse/parseByteSequence.d.ts +0 -3
- package/dist/parse/parseByteSequence.d.ts.map +0 -1
- package/dist/parse/parseByteSequence.js +0 -59
- package/dist/parse/parseByteSequence.js.map +0 -1
- package/dist/parse/parseDate.d.ts +0 -3
- package/dist/parse/parseDate.d.ts.map +0 -1
- package/dist/parse/parseDate.js +0 -32
- package/dist/parse/parseDate.js.map +0 -1
- package/dist/parse/parseDict.d.ts +0 -5
- package/dist/parse/parseDict.d.ts.map +0 -1
- package/dist/parse/parseDict.js +0 -90
- package/dist/parse/parseDict.js.map +0 -1
- package/dist/parse/parseError.d.ts +0 -2
- package/dist/parse/parseError.d.ts.map +0 -1
- package/dist/parse/parseError.js +0 -5
- package/dist/parse/parseError.js.map +0 -1
- package/dist/parse/parseInnerList.d.ts +0 -5
- package/dist/parse/parseInnerList.d.ts.map +0 -1
- package/dist/parse/parseInnerList.js +0 -62
- package/dist/parse/parseInnerList.js.map +0 -1
- package/dist/parse/parseIntegerOrDecimal.d.ts +0 -3
- package/dist/parse/parseIntegerOrDecimal.d.ts.map +0 -1
- package/dist/parse/parseIntegerOrDecimal.js +0 -123
- package/dist/parse/parseIntegerOrDecimal.js.map +0 -1
- package/dist/parse/parseItem.d.ts +0 -5
- package/dist/parse/parseItem.d.ts.map +0 -1
- package/dist/parse/parseItem.js +0 -25
- package/dist/parse/parseItem.js.map +0 -1
- package/dist/parse/parseItemOrInnerList.d.ts +0 -6
- package/dist/parse/parseItemOrInnerList.d.ts.map +0 -1
- package/dist/parse/parseItemOrInnerList.js +0 -22
- package/dist/parse/parseItemOrInnerList.js.map +0 -1
- package/dist/parse/parseKey.d.ts +0 -3
- package/dist/parse/parseKey.d.ts.map +0 -1
- package/dist/parse/parseKey.js +0 -40
- package/dist/parse/parseKey.js.map +0 -1
- package/dist/parse/parseList.d.ts +0 -5
- package/dist/parse/parseList.d.ts.map +0 -1
- package/dist/parse/parseList.js +0 -51
- package/dist/parse/parseList.js.map +0 -1
- package/dist/parse/parseParameters.d.ts +0 -5
- package/dist/parse/parseParameters.d.ts.map +0 -1
- package/dist/parse/parseParameters.js +0 -68
- package/dist/parse/parseParameters.js.map +0 -1
- package/dist/parse/parseString.d.ts +0 -3
- package/dist/parse/parseString.d.ts.map +0 -1
- package/dist/parse/parseString.js +0 -73
- package/dist/parse/parseString.js.map +0 -1
- package/dist/parse/parseToken.d.ts +0 -5
- package/dist/parse/parseToken.d.ts.map +0 -1
- package/dist/parse/parseToken.js +0 -35
- package/dist/parse/parseToken.js.map +0 -1
- package/dist/serialize/index.d.ts +0 -21
- package/dist/serialize/index.d.ts.map +0 -1
- package/dist/serialize/index.js +0 -21
- package/dist/serialize/index.js.map +0 -1
- package/dist/serialize/serializeBareItem.d.ts +0 -2
- package/dist/serialize/serializeBareItem.d.ts.map +0 -1
- package/dist/serialize/serializeBareItem.js +0 -69
- package/dist/serialize/serializeBareItem.js.map +0 -1
- package/dist/serialize/serializeBoolean.d.ts +0 -2
- package/dist/serialize/serializeBoolean.d.ts.map +0 -1
- package/dist/serialize/serializeBoolean.js +0 -25
- package/dist/serialize/serializeBoolean.js.map +0 -1
- package/dist/serialize/serializeByteSequence.d.ts +0 -2
- package/dist/serialize/serializeByteSequence.d.ts.map +0 -1
- package/dist/serialize/serializeByteSequence.js +0 -34
- package/dist/serialize/serializeByteSequence.js.map +0 -1
- package/dist/serialize/serializeDate.d.ts +0 -2
- package/dist/serialize/serializeDate.d.ts.map +0 -1
- package/dist/serialize/serializeDate.js +0 -13
- package/dist/serialize/serializeDate.js.map +0 -1
- package/dist/serialize/serializeDecimal.d.ts +0 -2
- package/dist/serialize/serializeDecimal.d.ts.map +0 -1
- package/dist/serialize/serializeDecimal.js +0 -46
- package/dist/serialize/serializeDecimal.js.map +0 -1
- package/dist/serialize/serializeDict.d.ts +0 -3
- package/dist/serialize/serializeDict.d.ts.map +0 -1
- package/dist/serialize/serializeDict.js +0 -74
- package/dist/serialize/serializeDict.js.map +0 -1
- package/dist/serialize/serializeError.d.ts +0 -2
- package/dist/serialize/serializeError.d.ts.map +0 -1
- package/dist/serialize/serializeError.js +0 -5
- package/dist/serialize/serializeError.js.map +0 -1
- package/dist/serialize/serializeInnerList.d.ts +0 -3
- package/dist/serialize/serializeInnerList.d.ts.map +0 -1
- package/dist/serialize/serializeInnerList.js +0 -28
- package/dist/serialize/serializeInnerList.js.map +0 -1
- package/dist/serialize/serializeInteger.d.ts +0 -2
- package/dist/serialize/serializeInteger.d.ts.map +0 -1
- package/dist/serialize/serializeInteger.js +0 -28
- package/dist/serialize/serializeInteger.js.map +0 -1
- package/dist/serialize/serializeItem.d.ts +0 -4
- package/dist/serialize/serializeItem.d.ts.map +0 -1
- package/dist/serialize/serializeItem.js +0 -26
- package/dist/serialize/serializeItem.js.map +0 -1
- package/dist/serialize/serializeKey.d.ts +0 -2
- package/dist/serialize/serializeKey.d.ts.map +0 -1
- package/dist/serialize/serializeKey.js +0 -28
- package/dist/serialize/serializeKey.js.map +0 -1
- package/dist/serialize/serializeList.d.ts +0 -4
- package/dist/serialize/serializeList.d.ts.map +0 -1
- package/dist/serialize/serializeList.js +0 -48
- package/dist/serialize/serializeList.js.map +0 -1
- package/dist/serialize/serializeParams.d.ts +0 -2
- package/dist/serialize/serializeParams.d.ts.map +0 -1
- package/dist/serialize/serializeParams.js +0 -40
- package/dist/serialize/serializeParams.js.map +0 -1
- package/dist/serialize/serializeString.d.ts +0 -2
- package/dist/serialize/serializeString.d.ts.map +0 -1
- package/dist/serialize/serializeString.js +0 -34
- package/dist/serialize/serializeString.js.map +0 -1
- package/dist/serialize/serializeToken.d.ts +0 -4
- package/dist/serialize/serializeToken.d.ts.map +0 -1
- package/dist/serialize/serializeToken.js +0 -11
- package/dist/serialize/serializeToken.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/utils/BARE_ITEM.d.ts +0 -2
- package/dist/utils/BARE_ITEM.d.ts.map +0 -1
- package/dist/utils/BARE_ITEM.js +0 -2
- package/dist/utils/BARE_ITEM.js.map +0 -1
- package/dist/utils/BOOLEAN.d.ts +0 -2
- package/dist/utils/BOOLEAN.d.ts.map +0 -1
- package/dist/utils/BOOLEAN.js +0 -2
- package/dist/utils/BOOLEAN.js.map +0 -1
- package/dist/utils/BYTES.d.ts +0 -2
- package/dist/utils/BYTES.d.ts.map +0 -1
- package/dist/utils/BYTES.js +0 -2
- package/dist/utils/BYTES.js.map +0 -1
- package/dist/utils/DATE.d.ts +0 -2
- package/dist/utils/DATE.d.ts.map +0 -1
- package/dist/utils/DATE.js +0 -2
- package/dist/utils/DATE.js.map +0 -1
- package/dist/utils/DECIMAL.d.ts +0 -2
- package/dist/utils/DECIMAL.d.ts.map +0 -1
- package/dist/utils/DECIMAL.js +0 -2
- package/dist/utils/DECIMAL.js.map +0 -1
- package/dist/utils/DICT.d.ts +0 -2
- package/dist/utils/DICT.d.ts.map +0 -1
- package/dist/utils/DICT.js +0 -2
- package/dist/utils/DICT.js.map +0 -1
- package/dist/utils/INNER.d.ts +0 -2
- package/dist/utils/INNER.d.ts.map +0 -1
- package/dist/utils/INNER.js +0 -2
- package/dist/utils/INNER.js.map +0 -1
- package/dist/utils/INTEGER.d.ts +0 -2
- package/dist/utils/INTEGER.d.ts.map +0 -1
- package/dist/utils/INTEGER.js +0 -2
- package/dist/utils/INTEGER.js.map +0 -1
- package/dist/utils/INTEGER_DECIMAL.d.ts +0 -2
- package/dist/utils/INTEGER_DECIMAL.d.ts.map +0 -1
- package/dist/utils/INTEGER_DECIMAL.js +0 -4
- package/dist/utils/INTEGER_DECIMAL.js.map +0 -1
- package/dist/utils/ITEM.d.ts +0 -2
- package/dist/utils/ITEM.d.ts.map +0 -1
- package/dist/utils/ITEM.js +0 -2
- package/dist/utils/ITEM.js.map +0 -1
- package/dist/utils/KEY.d.ts +0 -2
- package/dist/utils/KEY.d.ts.map +0 -1
- package/dist/utils/KEY.js +0 -2
- package/dist/utils/KEY.js.map +0 -1
- package/dist/utils/LIST.d.ts +0 -2
- package/dist/utils/LIST.d.ts.map +0 -1
- package/dist/utils/LIST.js +0 -2
- package/dist/utils/LIST.js.map +0 -1
- package/dist/utils/STRING.d.ts +0 -2
- package/dist/utils/STRING.d.ts.map +0 -1
- package/dist/utils/STRING.js +0 -2
- package/dist/utils/STRING.js.map +0 -1
- package/dist/utils/STRING_REGEX.d.ts +0 -2
- package/dist/utils/STRING_REGEX.d.ts.map +0 -1
- package/dist/utils/STRING_REGEX.js +0 -2
- package/dist/utils/STRING_REGEX.js.map +0 -1
- package/dist/utils/TOKEN.d.ts +0 -2
- package/dist/utils/TOKEN.d.ts.map +0 -1
- package/dist/utils/TOKEN.js +0 -2
- package/dist/utils/TOKEN.js.map +0 -1
- package/dist/utils/index.d.ts +0 -10
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -10
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/isInvalidInt.d.ts +0 -2
- package/dist/utils/isInvalidInt.d.ts.map +0 -1
- package/dist/utils/isInvalidInt.js +0 -4
- package/dist/utils/isInvalidInt.js.map +0 -1
- package/dist/utils/symbolToStr.d.ts +0 -13
- package/dist/utils/symbolToStr.d.ts.map +0 -1
- package/dist/utils/symbolToStr.js +0 -14
- package/dist/utils/symbolToStr.js.map +0 -1
- package/dist/utils/throwError.d.ts +0 -2
- package/dist/utils/throwError.d.ts.map +0 -1
- package/dist/utils/throwError.js +0 -19
- package/dist/utils/throwError.js.map +0 -1
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { parsedValue } from './ParsedValue.js';
|
|
2
|
-
import { parseBareItem } from './parseBareItem.js';
|
|
3
|
-
import { parseKey } from './parseKey.js';
|
|
4
|
-
// 4.2.3.2. Parsing Parameters
|
|
5
|
-
//
|
|
6
|
-
// Given an ASCII string as input_string, return an ordered map whose
|
|
7
|
-
// values are bare Items. input_string is modified to remove the parsed
|
|
8
|
-
// value.
|
|
9
|
-
//
|
|
10
|
-
// 1. Let parameters be an empty, ordered map.
|
|
11
|
-
//
|
|
12
|
-
// 2. While input_string is not empty:
|
|
13
|
-
//
|
|
14
|
-
// 1. If the first character of input_string is not ";", exit the
|
|
15
|
-
// loop.
|
|
16
|
-
//
|
|
17
|
-
// 2. Consume a ";" character from the beginning of input_string.
|
|
18
|
-
//
|
|
19
|
-
// 3. Discard any leading SP characters from input_string.
|
|
20
|
-
//
|
|
21
|
-
// 4. let param_name be the result of running Parsing a Key
|
|
22
|
-
// (Section 4.2.3.3) with input_string.
|
|
23
|
-
//
|
|
24
|
-
// 5. Let param_value be Boolean true.
|
|
25
|
-
//
|
|
26
|
-
// 6. If the first character of input_string is "=":
|
|
27
|
-
//
|
|
28
|
-
// 1. Consume the "=" character at the beginning of
|
|
29
|
-
// input_string.
|
|
30
|
-
//
|
|
31
|
-
// 2. Let param_value be the result of running Parsing a Bare
|
|
32
|
-
// Item (Section 4.2.3.1) with input_string.
|
|
33
|
-
//
|
|
34
|
-
// 7. Append key param_name with value param_value to parameters.
|
|
35
|
-
// If parameters already contains a name param_name (comparing
|
|
36
|
-
// character-for-character), overwrite its value.
|
|
37
|
-
//
|
|
38
|
-
// 3. Return parameters.
|
|
39
|
-
//
|
|
40
|
-
// Note that when duplicate Parameter keys are encountered, this has the
|
|
41
|
-
// effect of ignoring all but the last instance.
|
|
42
|
-
export function parseParameters(src, options) {
|
|
43
|
-
let parameters = undefined;
|
|
44
|
-
while (src.length > 0) {
|
|
45
|
-
if (src[0] !== ';') {
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
src = src.substring(1).trim();
|
|
49
|
-
const parsedKey = parseKey(src);
|
|
50
|
-
const key = parsedKey.value;
|
|
51
|
-
let value = true;
|
|
52
|
-
src = parsedKey.src;
|
|
53
|
-
if (src[0] === '=') {
|
|
54
|
-
src = src.substring(1);
|
|
55
|
-
const parsedBareItem = parseBareItem(src, options);
|
|
56
|
-
value = parsedBareItem.value;
|
|
57
|
-
src = parsedBareItem.src;
|
|
58
|
-
}
|
|
59
|
-
// initialize as object when params exists
|
|
60
|
-
if (parameters == null) {
|
|
61
|
-
parameters = {};
|
|
62
|
-
}
|
|
63
|
-
// override if param_name exists
|
|
64
|
-
parameters[key] = value;
|
|
65
|
-
}
|
|
66
|
-
return parsedValue(parameters, src);
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=parseParameters.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseParameters.js","sourceRoot":"","sources":["../../src/parse/parseParameters.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,+BAA+B;AAC/B,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,SAAS;AACT,EAAE;AACF,+CAA+C;AAC/C,EAAE;AACF,uCAAuC;AACvC,EAAE;AACF,sEAAsE;AACtE,gBAAgB;AAChB,EAAE;AACF,sEAAsE;AACtE,EAAE;AACF,+DAA+D;AAC/D,EAAE;AACF,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,2CAA2C;AAC3C,EAAE;AACF,yDAAyD;AACzD,EAAE;AACF,4DAA4D;AAC5D,4BAA4B;AAC5B,EAAE;AACF,sEAAsE;AACtE,wDAAwD;AACxD,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,yDAAyD;AACzD,EAAE;AACF,yBAAyB;AACzB,EAAE;AACF,wEAAwE;AACxE,gDAAgD;AAChD,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,OAAyB;IACrE,IAAI,UAAU,GAA6B,SAAS,CAAC;IACrD,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACpB,MAAM;QACP,CAAC;QAED,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC9B,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAChC,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,CAAC;QAC5B,IAAI,KAAK,GAAG,IAAI,CAAC;QACjB,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC;QAEpB,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACpB,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACvB,MAAM,cAAc,GAAG,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACnD,KAAK,GAAG,cAAc,CAAC,KAAY,CAAC;YACpC,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC;QAC1B,CAAC;QAED,0CAA0C;QAC1C,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;YACxB,UAAU,GAAG,EAAE,CAAC;QACjB,CAAC;QAED,gCAAgC;QAChC,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACzB,CAAC;IACD,OAAO,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import type { SfDecodeOptions } from '../SfDecodeOptions.js';\nimport type { SfParameters } from '../SfParameters.js';\nimport type { ParsedValue } from './ParsedValue.js';\nimport { parsedValue } from './ParsedValue.js';\nimport { parseBareItem } from './parseBareItem.js';\nimport { parseKey } from './parseKey.js';\n\n// 4.2.3.2. Parsing Parameters\n//\n// Given an ASCII string as input_string, return an ordered map whose\n// values are bare Items. input_string is modified to remove the parsed\n// value.\n//\n// 1. Let parameters be an empty, ordered map.\n//\n// 2. While input_string is not empty:\n//\n// 1. If the first character of input_string is not \";\", exit the\n// loop.\n//\n// 2. Consume a \";\" character from the beginning of input_string.\n//\n// 3. Discard any leading SP characters from input_string.\n//\n// 4. let param_name be the result of running Parsing a Key\n// (Section 4.2.3.3) with input_string.\n//\n// 5. Let param_value be Boolean true.\n//\n// 6. If the first character of input_string is \"=\":\n//\n// 1. Consume the \"=\" character at the beginning of\n// input_string.\n//\n// 2. Let param_value be the result of running Parsing a Bare\n// Item (Section 4.2.3.1) with input_string.\n//\n// 7. Append key param_name with value param_value to parameters.\n// If parameters already contains a name param_name (comparing\n// character-for-character), overwrite its value.\n//\n// 3. Return parameters.\n//\n// Note that when duplicate Parameter keys are encountered, this has the\n// effect of ignoring all but the last instance.\nexport function parseParameters(src: string, options?: SfDecodeOptions): ParsedValue<SfParameters | undefined> {\n\tlet parameters: SfParameters | undefined = undefined;\n\twhile (src.length > 0) {\n\t\tif (src[0] !== ';') {\n\t\t\tbreak;\n\t\t}\n\n\t\tsrc = src.substring(1).trim();\n\t\tconst parsedKey = parseKey(src);\n\t\tconst key = parsedKey.value;\n\t\tlet value = true;\n\t\tsrc = parsedKey.src;\n\n\t\tif (src[0] === '=') {\n\t\t\tsrc = src.substring(1);\n\t\t\tconst parsedBareItem = parseBareItem(src, options);\n\t\t\tvalue = parsedBareItem.value as any;\n\t\t\tsrc = parsedBareItem.src;\n\t\t}\n\n\t\t// initialize as object when params exists\n\t\tif (parameters == null) {\n\t\t\tparameters = {};\n\t\t}\n\n\t\t// override if param_name exists\n\t\tparameters[key] = value;\n\t}\n\treturn parsedValue(parameters, src);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseString.d.ts","sourceRoot":"","sources":["../../src/parse/parseString.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAyCpD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAsC5D"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { STRING } from '../utils/STRING.js';
|
|
2
|
-
import { STRING_REGEX } from '../utils/STRING_REGEX.js';
|
|
3
|
-
import { parsedValue } from './ParsedValue.js';
|
|
4
|
-
import { parseError } from './parseError.js';
|
|
5
|
-
// 4.2.5. Parsing a String
|
|
6
|
-
//
|
|
7
|
-
// Given an ASCII string as input_string, return an unquoted String.
|
|
8
|
-
// input_string is modified to remove the parsed value.
|
|
9
|
-
//
|
|
10
|
-
// 1. Let output_string be an empty string.
|
|
11
|
-
//
|
|
12
|
-
// 2. If the first character of input_string is not DQUOTE, fail
|
|
13
|
-
// parsing.
|
|
14
|
-
//
|
|
15
|
-
// 3. Discard the first character of input_string.
|
|
16
|
-
//
|
|
17
|
-
// 4. While input_string is not empty:
|
|
18
|
-
//
|
|
19
|
-
// 1. Let char be the result of consuming the first character of
|
|
20
|
-
// input_string.
|
|
21
|
-
//
|
|
22
|
-
// 2. If char is a backslash ("\"):
|
|
23
|
-
//
|
|
24
|
-
// 1. If input_string is now empty, fail parsing.
|
|
25
|
-
//
|
|
26
|
-
// 2. Let next_char be the result of consuming the first
|
|
27
|
-
// character of input_string.
|
|
28
|
-
//
|
|
29
|
-
// 3. If next_char is not DQUOTE or "\", fail parsing.
|
|
30
|
-
//
|
|
31
|
-
// 4. Append next_char to output_string.
|
|
32
|
-
//
|
|
33
|
-
// 3. Else, if char is DQUOTE, return output_string.
|
|
34
|
-
//
|
|
35
|
-
// 4. Else, if char is in the range %x00-1f or %x7f (i.e., is not
|
|
36
|
-
// in VCHAR or SP), fail parsing.
|
|
37
|
-
//
|
|
38
|
-
// 5. Else, append char to output_string.
|
|
39
|
-
//
|
|
40
|
-
// 5. Reached the end of input_string without finding a closing DQUOTE;
|
|
41
|
-
// fail parsing.
|
|
42
|
-
export function parseString(src) {
|
|
43
|
-
let output = '';
|
|
44
|
-
let i = 0;
|
|
45
|
-
if (src[i] !== `"`) {
|
|
46
|
-
throw parseError(src, STRING);
|
|
47
|
-
}
|
|
48
|
-
i++;
|
|
49
|
-
while (src.length > i) {
|
|
50
|
-
if (src[i] === `\\`) {
|
|
51
|
-
if (src.length <= i + 1) {
|
|
52
|
-
throw parseError(src, STRING);
|
|
53
|
-
}
|
|
54
|
-
i++;
|
|
55
|
-
if (src[i] !== `"` && src[i] !== `\\`) {
|
|
56
|
-
throw parseError(src, STRING);
|
|
57
|
-
}
|
|
58
|
-
output += src[i];
|
|
59
|
-
}
|
|
60
|
-
else if (src[i] === `"`) {
|
|
61
|
-
return parsedValue(output, src.substring(++i));
|
|
62
|
-
}
|
|
63
|
-
else if (STRING_REGEX.test(src[i])) {
|
|
64
|
-
throw parseError(src, STRING);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
output += src[i];
|
|
68
|
-
}
|
|
69
|
-
i++;
|
|
70
|
-
}
|
|
71
|
-
throw parseError(src, STRING);
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=parseString.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseString.js","sourceRoot":"","sources":["../../src/parse/parseString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,2BAA2B;AAC3B,EAAE;AACF,oEAAoE;AACpE,uDAAuD;AACvD,EAAE;AACF,4CAA4C;AAC5C,EAAE;AACF,iEAAiE;AACjE,eAAe;AACf,EAAE;AACF,mDAAmD;AACnD,EAAE;AACF,uCAAuC;AACvC,EAAE;AACF,qEAAqE;AACrE,wBAAwB;AACxB,EAAE;AACF,wCAAwC;AACxC,EAAE;AACF,0DAA0D;AAC1D,EAAE;AACF,iEAAiE;AACjE,yCAAyC;AACzC,EAAE;AACF,+DAA+D;AAC/D,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,yDAAyD;AACzD,EAAE;AACF,sEAAsE;AACtE,yCAAyC;AACzC,EAAE;AACF,8CAA8C;AAC9C,EAAE;AACF,wEAAwE;AACxE,oBAAoB;AACpB,MAAM,UAAU,WAAW,CAAC,GAAW;IACtC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACpB,MAAM,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED,CAAC,EAAE,CAAC;IAEJ,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACrB,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzB,MAAM,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAC/B,CAAC;YAED,CAAC,EAAE,CAAC;YAEJ,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;gBACvC,MAAM,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAC/B,CAAC;YAED,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;aACI,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACzB,OAAO,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAChD,CAAC;aACI,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACpC,MAAM,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC/B,CAAC;aACI,CAAC;YACL,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,CAAC,EAAE,CAAC;IACL,CAAC;IAED,MAAM,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import { STRING } from '../utils/STRING.js';\nimport { STRING_REGEX } from '../utils/STRING_REGEX.js';\nimport type { ParsedValue } from './ParsedValue.js';\nimport { parsedValue } from './ParsedValue.js';\nimport { parseError } from './parseError.js';\n\n// 4.2.5. Parsing a String\n//\n// Given an ASCII string as input_string, return an unquoted String.\n// input_string is modified to remove the parsed value.\n//\n// 1. Let output_string be an empty string.\n//\n// 2. If the first character of input_string is not DQUOTE, fail\n// parsing.\n//\n// 3. Discard the first character of input_string.\n//\n// 4. While input_string is not empty:\n//\n// 1. Let char be the result of consuming the first character of\n// input_string.\n//\n// 2. If char is a backslash (\"\\\"):\n//\n// 1. If input_string is now empty, fail parsing.\n//\n// 2. Let next_char be the result of consuming the first\n// character of input_string.\n//\n// 3. If next_char is not DQUOTE or \"\\\", fail parsing.\n//\n// 4. Append next_char to output_string.\n//\n// 3. Else, if char is DQUOTE, return output_string.\n//\n// 4. Else, if char is in the range %x00-1f or %x7f (i.e., is not\n// in VCHAR or SP), fail parsing.\n//\n// 5. Else, append char to output_string.\n//\n// 5. Reached the end of input_string without finding a closing DQUOTE;\n// fail parsing.\nexport function parseString(src: string): ParsedValue<string> {\n\tlet output = '';\n\tlet i = 0;\n\n\tif (src[i] !== `\"`) {\n\t\tthrow parseError(src, STRING);\n\t}\n\n\ti++;\n\n\twhile (src.length > i) {\n\t\tif (src[i] === `\\\\`) {\n\t\t\tif (src.length <= i + 1) {\n\t\t\t\tthrow parseError(src, STRING);\n\t\t\t}\n\n\t\t\ti++;\n\n\t\t\tif (src[i] !== `\"` && src[i] !== `\\\\`) {\n\t\t\t\tthrow parseError(src, STRING);\n\t\t\t}\n\n\t\t\toutput += src[i];\n\t\t}\n\t\telse if (src[i] === `\"`) {\n\t\t\treturn parsedValue(output, src.substring(++i));\n\t\t}\n\t\telse if (STRING_REGEX.test(src[i])) {\n\t\t\tthrow parseError(src, STRING);\n\t\t}\n\t\telse {\n\t\t\toutput += src[i];\n\t\t}\n\n\t\ti++;\n\t}\n\n\tthrow parseError(src, STRING);\n}\n"]}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { SfDecodeOptions } from '../SfDecodeOptions.js';
|
|
2
|
-
import { SfToken } from '../SfToken.js';
|
|
3
|
-
import type { ParsedValue } from './ParsedValue.js';
|
|
4
|
-
export declare function parseToken(src: string, options?: SfDecodeOptions): ParsedValue<symbol | SfToken>;
|
|
5
|
-
//# sourceMappingURL=parseToken.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseToken.d.ts","sourceRoot":"","sources":["../../src/parse/parseToken.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAyBpD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,WAAW,CAAC,MAAM,GAAG,OAAO,CAAC,CAahG"}
|
package/dist/parse/parseToken.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { SfToken } from '../SfToken.js';
|
|
2
|
-
import { TOKEN } from '../utils/TOKEN.js';
|
|
3
|
-
import { parsedValue } from './ParsedValue.js';
|
|
4
|
-
import { parseError } from './parseError.js';
|
|
5
|
-
// 4.2.6. Parsing a Token
|
|
6
|
-
//
|
|
7
|
-
// Given an ASCII string as input_string, return a Token. input_string
|
|
8
|
-
// is modified to remove the parsed value.
|
|
9
|
-
//
|
|
10
|
-
// 1. If the first character of input_string is not ALPHA or "*", fail
|
|
11
|
-
// parsing.
|
|
12
|
-
//
|
|
13
|
-
// 2. Let output_string be an empty string.
|
|
14
|
-
//
|
|
15
|
-
// 3. While input_string is not empty:
|
|
16
|
-
//
|
|
17
|
-
// 1. If the first character of input_string is not in tchar, ":"
|
|
18
|
-
// or "/", return output_string.
|
|
19
|
-
//
|
|
20
|
-
// 2. Let char be the result of consuming the first character of
|
|
21
|
-
// input_string.
|
|
22
|
-
//
|
|
23
|
-
// 3. Append char to output_string.
|
|
24
|
-
//
|
|
25
|
-
// 4. Return output_string.
|
|
26
|
-
export function parseToken(src, options) {
|
|
27
|
-
if (/^[a-zA-Z*]$/.test(src[0]) === false) {
|
|
28
|
-
throw parseError(src, TOKEN);
|
|
29
|
-
}
|
|
30
|
-
const re = /^([!#$%&'*+\-.^_`|~\w:/]+)/g;
|
|
31
|
-
const value = re.exec(src)[1];
|
|
32
|
-
src = src.substring(re.lastIndex);
|
|
33
|
-
return parsedValue((options === null || options === void 0 ? void 0 : options.useSymbol) === false ? new SfToken(value) : Symbol.for(value), src);
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=parseToken.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseToken.js","sourceRoot":"","sources":["../../src/parse/parseToken.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,0BAA0B;AAC1B,EAAE;AACF,sEAAsE;AACtE,0CAA0C;AAC1C,EAAE;AACF,uEAAuE;AACvE,eAAe;AACf,EAAE;AACF,4CAA4C;AAC5C,EAAE;AACF,uCAAuC;AACvC,EAAE;AACF,sEAAsE;AACtE,wCAAwC;AACxC,EAAE;AACF,qEAAqE;AACrE,wBAAwB;AACxB,EAAE;AACF,wCAAwC;AACxC,EAAE;AACF,4BAA4B;AAC5B,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,OAAyB;IAChE,IAAI,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC;QAC1C,MAAM,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,EAAE,GAAG,6BAA6B,CAAC;IACzC,MAAM,KAAK,GAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAS,CAAC,CAAC,CAAC,CAAC;IACvC,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;IAElC,OAAO,WAAW,CACjB,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,MAAK,KAAK,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EACrE,GAAG,CACH,CAAC;AACH,CAAC","sourcesContent":["import type { SfDecodeOptions } from '../SfDecodeOptions.js';\nimport { SfToken } from '../SfToken.js';\nimport { TOKEN } from '../utils/TOKEN.js';\nimport type { ParsedValue } from './ParsedValue.js';\nimport { parsedValue } from './ParsedValue.js';\nimport { parseError } from './parseError.js';\n\n// 4.2.6. Parsing a Token\n//\n// Given an ASCII string as input_string, return a Token. input_string\n// is modified to remove the parsed value.\n//\n// 1. If the first character of input_string is not ALPHA or \"*\", fail\n// parsing.\n//\n// 2. Let output_string be an empty string.\n//\n// 3. While input_string is not empty:\n//\n// 1. If the first character of input_string is not in tchar, \":\"\n// or \"/\", return output_string.\n//\n// 2. Let char be the result of consuming the first character of\n// input_string.\n//\n// 3. Append char to output_string.\n//\n// 4. Return output_string.\nexport function parseToken(src: string, options?: SfDecodeOptions): ParsedValue<symbol | SfToken> {\n\tif (/^[a-zA-Z*]$/.test(src[0]) === false) {\n\t\tthrow parseError(src, TOKEN);\n\t}\n\n\tconst re = /^([!#$%&'*+\\-.^_`|~\\w:/]+)/g;\n\tconst value = (re.exec(src) as any)[1];\n\tsrc = src.substring(re.lastIndex);\n\n\treturn parsedValue(\n\t\toptions?.useSymbol === false ? new SfToken(value) : Symbol.for(value),\n\t\tsrc,\n\t);\n}\n"]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Serialization utilities for structured fields.
|
|
3
|
-
*
|
|
4
|
-
* @packageDocumentation
|
|
5
|
-
*/
|
|
6
|
-
export * from './serializeBareItem.js';
|
|
7
|
-
export * from './serializeBoolean.js';
|
|
8
|
-
export * from './serializeByteSequence.js';
|
|
9
|
-
export * from './serializeDate.js';
|
|
10
|
-
export * from './serializeDecimal.js';
|
|
11
|
-
export * from './serializeDict.js';
|
|
12
|
-
export * from './serializeError.js';
|
|
13
|
-
export * from './serializeInnerList.js';
|
|
14
|
-
export * from './serializeInteger.js';
|
|
15
|
-
export * from './serializeItem.js';
|
|
16
|
-
export * from './serializeKey.js';
|
|
17
|
-
export * from './serializeList.js';
|
|
18
|
-
export * from './serializeParams.js';
|
|
19
|
-
export * from './serializeString.js';
|
|
20
|
-
export * from './serializeToken.js';
|
|
21
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/serialize/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC"}
|
package/dist/serialize/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Serialization utilities for structured fields.
|
|
3
|
-
*
|
|
4
|
-
* @packageDocumentation
|
|
5
|
-
*/
|
|
6
|
-
export * from './serializeBareItem.js';
|
|
7
|
-
export * from './serializeBoolean.js';
|
|
8
|
-
export * from './serializeByteSequence.js';
|
|
9
|
-
export * from './serializeDate.js';
|
|
10
|
-
export * from './serializeDecimal.js';
|
|
11
|
-
export * from './serializeDict.js';
|
|
12
|
-
export * from './serializeError.js';
|
|
13
|
-
export * from './serializeInnerList.js';
|
|
14
|
-
export * from './serializeInteger.js';
|
|
15
|
-
export * from './serializeItem.js';
|
|
16
|
-
export * from './serializeKey.js';
|
|
17
|
-
export * from './serializeList.js';
|
|
18
|
-
export * from './serializeParams.js';
|
|
19
|
-
export * from './serializeString.js';
|
|
20
|
-
export * from './serializeToken.js';
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/serialize/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC","sourcesContent":["/**\n * Serialization utilities for structured fields.\n *\n * @packageDocumentation\n */\nexport * from './serializeBareItem.js';\nexport * from './serializeBoolean.js';\nexport * from './serializeByteSequence.js';\nexport * from './serializeDate.js';\nexport * from './serializeDecimal.js';\nexport * from './serializeDict.js';\nexport * from './serializeError.js';\nexport * from './serializeInnerList.js';\nexport * from './serializeInteger.js';\nexport * from './serializeItem.js';\nexport * from './serializeKey.js';\nexport * from './serializeList.js';\nexport * from './serializeParams.js';\nexport * from './serializeString.js';\nexport * from './serializeToken.js';\n\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializeBareItem.d.ts","sourceRoot":"","sources":["../../src/serialize/serializeBareItem.ts"],"names":[],"mappings":"AAsCA,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,CA+BpD"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { SfToken } from '../SfToken.js';
|
|
2
|
-
import { BARE_ITEM } from '../utils/BARE_ITEM.js';
|
|
3
|
-
import { serializeBoolean } from './serializeBoolean.js';
|
|
4
|
-
import { serializeByteSequence } from './serializeByteSequence.js';
|
|
5
|
-
import { serializeDate } from './serializeDate.js';
|
|
6
|
-
import { serializeDecimal } from './serializeDecimal.js';
|
|
7
|
-
import { serializeError } from './serializeError.js';
|
|
8
|
-
import { serializeInteger } from './serializeInteger.js';
|
|
9
|
-
import { serializeString } from './serializeString.js';
|
|
10
|
-
import { serializeToken } from './serializeToken.js';
|
|
11
|
-
// 4.1.3.1. Serializing a Bare Item
|
|
12
|
-
//
|
|
13
|
-
// Given an Item as input_item, return an ASCII string suitable for use
|
|
14
|
-
// in a HTTP field value.
|
|
15
|
-
//
|
|
16
|
-
// 1. If input_item is an Integer, return the result of running
|
|
17
|
-
// Serializing an Integer (Section 4.1.4) with input_item.
|
|
18
|
-
//
|
|
19
|
-
// 2. If input_item is a Decimal, return the result of running
|
|
20
|
-
// Serializing a Decimal (Section 4.1.5) with input_item.
|
|
21
|
-
//
|
|
22
|
-
// 3. If input_item is a String, return the result of running
|
|
23
|
-
// Serializing a String (Section 4.1.6) with input_item.
|
|
24
|
-
//
|
|
25
|
-
// 4. If input_item is a Token, return the result of running
|
|
26
|
-
// Serializing a Token (Section 4.1.7) with input_item.
|
|
27
|
-
//
|
|
28
|
-
// 5. If input_item is a Boolean, return the result of running
|
|
29
|
-
// Serializing a Boolean (Section 4.1.9) with input_item.
|
|
30
|
-
//
|
|
31
|
-
// 6. If input_item is a Byte Sequence, return the result of running
|
|
32
|
-
// Serializing a Byte Sequence (Section 4.1.8) with input_item.
|
|
33
|
-
//
|
|
34
|
-
// 7. If input_item is a Date, return the result of running Serializing
|
|
35
|
-
// a Date (Section 4.1.10) with input_item.
|
|
36
|
-
//
|
|
37
|
-
// 8. Otherwise, fail serialization.
|
|
38
|
-
export function serializeBareItem(value) {
|
|
39
|
-
switch (typeof value) {
|
|
40
|
-
case 'number':
|
|
41
|
-
if (!Number.isFinite(value)) {
|
|
42
|
-
throw serializeError(value, BARE_ITEM);
|
|
43
|
-
}
|
|
44
|
-
if (Number.isInteger(value)) {
|
|
45
|
-
return serializeInteger(value);
|
|
46
|
-
}
|
|
47
|
-
return serializeDecimal(value);
|
|
48
|
-
case 'string':
|
|
49
|
-
return serializeString(value);
|
|
50
|
-
case 'symbol':
|
|
51
|
-
return serializeToken(value);
|
|
52
|
-
case 'boolean':
|
|
53
|
-
return serializeBoolean(value);
|
|
54
|
-
case 'object':
|
|
55
|
-
if (value instanceof Date) {
|
|
56
|
-
return serializeDate(value);
|
|
57
|
-
}
|
|
58
|
-
if (value instanceof Uint8Array) {
|
|
59
|
-
return serializeByteSequence(value);
|
|
60
|
-
}
|
|
61
|
-
if (value instanceof SfToken) {
|
|
62
|
-
return serializeToken(value);
|
|
63
|
-
}
|
|
64
|
-
default:
|
|
65
|
-
// fail
|
|
66
|
-
throw serializeError(value, BARE_ITEM);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=serializeBareItem.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializeBareItem.js","sourceRoot":"","sources":["../../src/serialize/serializeBareItem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,oCAAoC;AACpC,EAAE;AACF,uEAAuE;AACvE,yBAAyB;AACzB,EAAE;AACF,gEAAgE;AAChE,8DAA8D;AAC9D,EAAE;AACF,+DAA+D;AAC/D,6DAA6D;AAC7D,EAAE;AACF,8DAA8D;AAC9D,4DAA4D;AAC5D,EAAE;AACF,6DAA6D;AAC7D,2DAA2D;AAC3D,EAAE;AACF,+DAA+D;AAC/D,6DAA6D;AAC7D,EAAE;AACF,qEAAqE;AACrE,mEAAmE;AACnE,EAAE;AACF,wEAAwE;AACxE,+CAA+C;AAC/C,EAAE;AACF,qCAAqC;AACrC,MAAM,UAAU,iBAAiB,CAAC,KAAU;IAC3C,QAAQ,OAAO,KAAK,EAAE,CAAC;QACtB,KAAK,QAAQ;YACZ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7B,MAAM,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YACxC,CAAC;YAED,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7B,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC;YACD,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAChC,KAAK,QAAQ;YACZ,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;QAC/B,KAAK,QAAQ;YACZ,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;QAC9B,KAAK,SAAS;YACb,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAChC,KAAK,QAAQ;YACZ,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;gBAC3B,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;YAC7B,CAAC;YACD,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;gBACjC,OAAO,qBAAqB,CAAC,KAAK,CAAC,CAAC;YACrC,CAAC;YACD,IAAI,KAAK,YAAY,OAAO,EAAE,CAAC;gBAC9B,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC;QACF;YACC,OAAO;YACP,MAAM,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACzC,CAAC;AACF,CAAC","sourcesContent":["import { SfToken } from '../SfToken.js';\nimport { BARE_ITEM } from '../utils/BARE_ITEM.js';\nimport { serializeBoolean } from './serializeBoolean.js';\nimport { serializeByteSequence } from './serializeByteSequence.js';\nimport { serializeDate } from './serializeDate.js';\nimport { serializeDecimal } from './serializeDecimal.js';\nimport { serializeError } from './serializeError.js';\nimport { serializeInteger } from './serializeInteger.js';\nimport { serializeString } from './serializeString.js';\nimport { serializeToken } from './serializeToken.js';\n\n// 4.1.3.1. Serializing a Bare Item\n//\n// Given an Item as input_item, return an ASCII string suitable for use\n// in a HTTP field value.\n//\n// 1. If input_item is an Integer, return the result of running\n// Serializing an Integer (Section 4.1.4) with input_item.\n//\n// 2. If input_item is a Decimal, return the result of running\n// Serializing a Decimal (Section 4.1.5) with input_item.\n//\n// 3. If input_item is a String, return the result of running\n// Serializing a String (Section 4.1.6) with input_item.\n//\n// 4. If input_item is a Token, return the result of running\n// Serializing a Token (Section 4.1.7) with input_item.\n//\n// 5. If input_item is a Boolean, return the result of running\n// Serializing a Boolean (Section 4.1.9) with input_item.\n//\n// 6. If input_item is a Byte Sequence, return the result of running\n// Serializing a Byte Sequence (Section 4.1.8) with input_item.\n//\n// 7. If input_item is a Date, return the result of running Serializing\n// a Date (Section 4.1.10) with input_item.\n//\n// 8. Otherwise, fail serialization.\nexport function serializeBareItem(value: any): string {\n\tswitch (typeof value) {\n\t\tcase 'number':\n\t\t\tif (!Number.isFinite(value)) {\n\t\t\t\tthrow serializeError(value, BARE_ITEM);\n\t\t\t}\n\n\t\t\tif (Number.isInteger(value)) {\n\t\t\t\treturn serializeInteger(value);\n\t\t\t}\n\t\t\treturn serializeDecimal(value);\n\t\tcase 'string':\n\t\t\treturn serializeString(value);\n\t\tcase 'symbol':\n\t\t\treturn serializeToken(value);\n\t\tcase 'boolean':\n\t\t\treturn serializeBoolean(value);\n\t\tcase 'object':\n\t\t\tif (value instanceof Date) {\n\t\t\t\treturn serializeDate(value);\n\t\t\t}\n\t\t\tif (value instanceof Uint8Array) {\n\t\t\t\treturn serializeByteSequence(value);\n\t\t\t}\n\t\t\tif (value instanceof SfToken) {\n\t\t\t\treturn serializeToken(value);\n\t\t\t}\n\t\tdefault:\n\t\t\t// fail\n\t\t\tthrow serializeError(value, BARE_ITEM);\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializeBoolean.d.ts","sourceRoot":"","sources":["../../src/serialize/serializeBoolean.ts"],"names":[],"mappings":"AAmBA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKvD"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { BOOLEAN } from '../utils/BOOLEAN.js';
|
|
2
|
-
import { serializeError } from './serializeError.js';
|
|
3
|
-
// 4.1.9. Serializing a Boolean
|
|
4
|
-
//
|
|
5
|
-
// Given a Boolean as input_boolean, return an ASCII string suitable for
|
|
6
|
-
// use in a HTTP field value.
|
|
7
|
-
//
|
|
8
|
-
// 1. If input_boolean is not a boolean, fail serialization.
|
|
9
|
-
//
|
|
10
|
-
// 2. Let output be an empty string.
|
|
11
|
-
//
|
|
12
|
-
// 3. Append "?" to output.
|
|
13
|
-
//
|
|
14
|
-
// 4. If input_boolean is true, append "1" to output.
|
|
15
|
-
//
|
|
16
|
-
// 5. If input_boolean is false, append "0" to output.
|
|
17
|
-
//
|
|
18
|
-
// 6. Return output.
|
|
19
|
-
export function serializeBoolean(value) {
|
|
20
|
-
if (typeof value !== 'boolean') {
|
|
21
|
-
throw serializeError(value, BOOLEAN);
|
|
22
|
-
}
|
|
23
|
-
return value ? '?1' : '?0';
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=serializeBoolean.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializeBoolean.js","sourceRoot":"","sources":["../../src/serialize/serializeBoolean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,gCAAgC;AAChC,EAAE;AACF,wEAAwE;AACxE,6BAA6B;AAC7B,EAAE;AACF,6DAA6D;AAC7D,EAAE;AACF,qCAAqC;AACrC,EAAE;AACF,4BAA4B;AAC5B,EAAE;AACF,sDAAsD;AACtD,EAAE;AACF,uDAAuD;AACvD,EAAE;AACF,qBAAqB;AACrB,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC9C,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAChC,MAAM,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5B,CAAC","sourcesContent":["import { BOOLEAN } from '../utils/BOOLEAN.js';\nimport { serializeError } from './serializeError.js';\n\n// 4.1.9. Serializing a Boolean\n//\n// Given a Boolean as input_boolean, return an ASCII string suitable for\n// use in a HTTP field value.\n//\n// 1. If input_boolean is not a boolean, fail serialization.\n//\n// 2. Let output be an empty string.\n//\n// 3. Append \"?\" to output.\n//\n// 4. If input_boolean is true, append \"1\" to output.\n//\n// 5. If input_boolean is false, append \"0\" to output.\n//\n// 6. Return output.\nexport function serializeBoolean(value: boolean): string {\n\tif (typeof value !== 'boolean') {\n\t\tthrow serializeError(value, BOOLEAN);\n\t}\n\treturn value ? '?1' : '?0';\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializeByteSequence.d.ts","sourceRoot":"","sources":["../../src/serialize/serializeByteSequence.ts"],"names":[],"mappings":"AA4BA,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,UAAU,UAKtD"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { encodeBase64 } from '@svta/cml-utils/encodeBase64.js';
|
|
2
|
-
import { BYTES } from '../utils/BYTES.js';
|
|
3
|
-
import { serializeError } from './serializeError.js';
|
|
4
|
-
// 4.1.8. Serializing a Byte Sequence
|
|
5
|
-
//
|
|
6
|
-
// Given a Byte Sequence as input_bytes, return an ASCII string suitable
|
|
7
|
-
// for use in a HTTP field value.
|
|
8
|
-
//
|
|
9
|
-
// 1. If input_bytes is not a sequence of bytes, fail serialization.
|
|
10
|
-
//
|
|
11
|
-
// 2. Let output be an empty string.
|
|
12
|
-
//
|
|
13
|
-
// 3. Append ":" to output.
|
|
14
|
-
//
|
|
15
|
-
// 4. Append the result of base64-encoding input_bytes as per
|
|
16
|
-
// [RFC4648], Section 4, taking account of the requirements below.
|
|
17
|
-
//
|
|
18
|
-
// 5. Append ":" to output.
|
|
19
|
-
//
|
|
20
|
-
// 6. Return output.
|
|
21
|
-
//
|
|
22
|
-
// The encoded data is required to be padded with "=", as per [RFC4648],
|
|
23
|
-
// Section 3.2.
|
|
24
|
-
//
|
|
25
|
-
// Likewise, encoded data SHOULD have pad bits set to zero, as per
|
|
26
|
-
// [RFC4648], Section 3.5, unless it is not possible to do so due to
|
|
27
|
-
// implementation constraints.
|
|
28
|
-
export function serializeByteSequence(value) {
|
|
29
|
-
if (ArrayBuffer.isView(value) === false) {
|
|
30
|
-
throw serializeError(value, BYTES);
|
|
31
|
-
}
|
|
32
|
-
return `:${encodeBase64(value)}:`;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=serializeByteSequence.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializeByteSequence.js","sourceRoot":"","sources":["../../src/serialize/serializeByteSequence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,sCAAsC;AACtC,EAAE;AACF,wEAAwE;AACxE,iCAAiC;AACjC,EAAE;AACF,qEAAqE;AACrE,EAAE;AACF,qCAAqC;AACrC,EAAE;AACF,4BAA4B;AAC5B,EAAE;AACF,8DAA8D;AAC9D,sEAAsE;AACtE,EAAE;AACF,4BAA4B;AAC5B,EAAE;AACF,qBAAqB;AACrB,EAAE;AACF,wEAAwE;AACxE,eAAe;AACf,EAAE;AACF,kEAAkE;AAClE,oEAAoE;AACpE,8BAA8B;AAC9B,MAAM,UAAU,qBAAqB,CAAC,KAAiB;IACtD,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,KAAK,EAAE,CAAC;QACzC,MAAM,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,IAAI,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC;AACnC,CAAC","sourcesContent":["import { encodeBase64 } from '@svta/cml-utils/encodeBase64.js';\nimport { BYTES } from '../utils/BYTES.js';\nimport { serializeError } from './serializeError.js';\n\n// 4.1.8. Serializing a Byte Sequence\n//\n// Given a Byte Sequence as input_bytes, return an ASCII string suitable\n// for use in a HTTP field value.\n//\n// 1. If input_bytes is not a sequence of bytes, fail serialization.\n//\n// 2. Let output be an empty string.\n//\n// 3. Append \":\" to output.\n//\n// 4. Append the result of base64-encoding input_bytes as per\n// [RFC4648], Section 4, taking account of the requirements below.\n//\n// 5. Append \":\" to output.\n//\n// 6. Return output.\n//\n// The encoded data is required to be padded with \"=\", as per [RFC4648],\n// Section 3.2.\n//\n// Likewise, encoded data SHOULD have pad bits set to zero, as per\n// [RFC4648], Section 3.5, unless it is not possible to do so due to\n// implementation constraints.\nexport function serializeByteSequence(value: Uint8Array) {\n\tif (ArrayBuffer.isView(value) === false) {\n\t\tthrow serializeError(value, BYTES);\n\t}\n\treturn `:${encodeBase64(value)}:`;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializeDate.d.ts","sourceRoot":"","sources":["../../src/serialize/serializeDate.ts"],"names":[],"mappings":"AAUA,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,UAExC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { serializeInteger } from './serializeInteger.js';
|
|
2
|
-
// 4.1.10. Serializing a Date
|
|
3
|
-
//
|
|
4
|
-
// Given a Date as input_integer, return an ASCII string suitable for
|
|
5
|
-
// use in an HTTP field value.
|
|
6
|
-
// 1. Let output be "@".
|
|
7
|
-
// 2. Append to output the result of running Serializing an Integer
|
|
8
|
-
// with input_date (Section 4.1.4).
|
|
9
|
-
// 3. Return output.
|
|
10
|
-
export function serializeDate(value) {
|
|
11
|
-
return `@${serializeInteger(value.getTime() / 1000)}`;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=serializeDate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializeDate.js","sourceRoot":"","sources":["../../src/serialize/serializeDate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,8BAA8B;AAC9B,EAAE;AACF,qEAAqE;AACrE,8BAA8B;AAC9B,yBAAyB;AACzB,oEAAoE;AACpE,uCAAuC;AACvC,qBAAqB;AACrB,MAAM,UAAU,aAAa,CAAC,KAAW;IACxC,OAAO,IAAI,gBAAgB,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;AACvD,CAAC","sourcesContent":["import { serializeInteger } from './serializeInteger.js';\n\n// 4.1.10. Serializing a Date\n//\n// Given a Date as input_integer, return an ASCII string suitable for\n// use in an HTTP field value.\n// 1. Let output be \"@\".\n// 2. Append to output the result of running Serializing an Integer\n// with input_date (Section 4.1.4).\n// 3. Return output.\nexport function serializeDate(value: Date) {\n\treturn `@${serializeInteger(value.getTime() / 1000)}`;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializeDecimal.d.ts","sourceRoot":"","sources":["../../src/serialize/serializeDecimal.ts"],"names":[],"mappings":"AAsCA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOtD"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { roundToEven } from '@svta/cml-utils/roundToEven.js';
|
|
2
|
-
import { DECIMAL } from '../utils/DECIMAL.js';
|
|
3
|
-
import { serializeError } from './serializeError.js';
|
|
4
|
-
// 4.1.5. Serializing a Decimal
|
|
5
|
-
//
|
|
6
|
-
// Given a decimal number as input_decimal, return an ASCII string
|
|
7
|
-
// suitable for use in a HTTP field value.
|
|
8
|
-
//
|
|
9
|
-
// 1. If input_decimal is not a decimal number, fail serialization.
|
|
10
|
-
//
|
|
11
|
-
// 2. If input_decimal has more than three significant digits to the
|
|
12
|
-
// right of the decimal point, round it to three decimal places,
|
|
13
|
-
// rounding the final digit to the nearest value, or to the even
|
|
14
|
-
// value if it is equidistant.
|
|
15
|
-
//
|
|
16
|
-
// 3. If input_decimal has more than 12 significant digits to the left
|
|
17
|
-
// of the decimal point after rounding, fail serialization.
|
|
18
|
-
//
|
|
19
|
-
// 4. Let output be an empty string.
|
|
20
|
-
//
|
|
21
|
-
// 5. If input_decimal is less than (but not equal to) 0, append "-"
|
|
22
|
-
// to output.
|
|
23
|
-
//
|
|
24
|
-
// 6. Append input_decimal's integer component represented in base 10
|
|
25
|
-
// (using only decimal digits) to output; if it is zero, append
|
|
26
|
-
// "0".
|
|
27
|
-
//
|
|
28
|
-
// 7. Append "." to output.
|
|
29
|
-
//
|
|
30
|
-
// 8. If input_decimal's fractional component is zero, append "0" to
|
|
31
|
-
// output.
|
|
32
|
-
//
|
|
33
|
-
// 9. Otherwise, append the significant digits of input_decimal's
|
|
34
|
-
// fractional component represented in base 10 (using only decimal
|
|
35
|
-
// digits) to output.
|
|
36
|
-
//
|
|
37
|
-
// 10. Return output.
|
|
38
|
-
export function serializeDecimal(value) {
|
|
39
|
-
const roundedValue = roundToEven(value, 3); // round to 3 decimal places
|
|
40
|
-
if (Math.floor(Math.abs(roundedValue)).toString().length > 12) {
|
|
41
|
-
throw serializeError(value, DECIMAL);
|
|
42
|
-
}
|
|
43
|
-
const stringValue = roundedValue.toString();
|
|
44
|
-
return stringValue.includes('.') ? stringValue : `${stringValue}.0`;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=serializeDecimal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializeDecimal.js","sourceRoot":"","sources":["../../src/serialize/serializeDecimal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,gCAAgC;AAChC,EAAE;AACF,kEAAkE;AAClE,0CAA0C;AAC1C,EAAE;AACF,qEAAqE;AACrE,EAAE;AACF,sEAAsE;AACtE,qEAAqE;AACrE,qEAAqE;AACrE,mCAAmC;AACnC,EAAE;AACF,wEAAwE;AACxE,gEAAgE;AAChE,EAAE;AACF,sCAAsC;AACtC,EAAE;AACF,sEAAsE;AACtE,kBAAkB;AAClB,EAAE;AACF,uEAAuE;AACvE,oEAAoE;AACpE,YAAY;AACZ,EAAE;AACF,6BAA6B;AAC7B,EAAE;AACF,sEAAsE;AACtE,eAAe;AACf,EAAE;AACF,mEAAmE;AACnE,uEAAuE;AACvE,0BAA0B;AAC1B,EAAE;AACF,sBAAsB;AACtB,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC7C,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,4BAA4B;IACxE,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QAC/D,MAAM,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;IACD,MAAM,WAAW,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;IAC5C,OAAO,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,IAAI,CAAC;AACrE,CAAC","sourcesContent":["import { roundToEven } from '@svta/cml-utils/roundToEven.js';\nimport { DECIMAL } from '../utils/DECIMAL.js';\nimport { serializeError } from './serializeError.js';\n\n// 4.1.5. Serializing a Decimal\n//\n// Given a decimal number as input_decimal, return an ASCII string\n// suitable for use in a HTTP field value.\n//\n// 1. If input_decimal is not a decimal number, fail serialization.\n//\n// 2. If input_decimal has more than three significant digits to the\n// right of the decimal point, round it to three decimal places,\n// rounding the final digit to the nearest value, or to the even\n// value if it is equidistant.\n//\n// 3. If input_decimal has more than 12 significant digits to the left\n// of the decimal point after rounding, fail serialization.\n//\n// 4. Let output be an empty string.\n//\n// 5. If input_decimal is less than (but not equal to) 0, append \"-\"\n// to output.\n//\n// 6. Append input_decimal's integer component represented in base 10\n// (using only decimal digits) to output; if it is zero, append\n// \"0\".\n//\n// 7. Append \".\" to output.\n//\n// 8. If input_decimal's fractional component is zero, append \"0\" to\n// output.\n//\n// 9. Otherwise, append the significant digits of input_decimal's\n// fractional component represented in base 10 (using only decimal\n// digits) to output.\n//\n// 10. Return output.\nexport function serializeDecimal(value: number): string {\n\tconst roundedValue = roundToEven(value, 3); // round to 3 decimal places\n\tif (Math.floor(Math.abs(roundedValue)).toString().length > 12) {\n\t\tthrow serializeError(value, DECIMAL);\n\t}\n\tconst stringValue = roundedValue.toString();\n\treturn stringValue.includes('.') ? stringValue : `${stringValue}.0`;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializeDict.d.ts","sourceRoot":"","sources":["../../src/serialize/serializeDict.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AA+C7D,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAE,eAAsC,GAAG,MAAM,CA6BnI"}
|