url-safe-bitpacking 0.2.0 → 0.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.
Files changed (56) hide show
  1. package/README.md +20 -60
  2. package/dist/enums/dataTypes.d.ts +16 -4
  3. package/dist/factory/arrayFactory.d.ts +3 -2
  4. package/dist/factory/booleanFactory.d.ts +2 -1
  5. package/dist/factory/enumArrayFactory.d.ts +3 -2
  6. package/dist/factory/enumFactory.d.ts +3 -1
  7. package/dist/factory/enumOptionsFactory.d.ts +3 -2
  8. package/dist/factory/factory.d.ts +14 -12
  9. package/dist/factory/floatFactory.d.ts +2 -2
  10. package/dist/factory/intFactory.d.ts +2 -1
  11. package/dist/factory/objectFactory.d.ts +3 -0
  12. package/dist/factory/optionalFactory.d.ts +3 -2
  13. package/dist/factory/utils.d.ts +12 -2
  14. package/dist/factory/versionFactory.d.ts +2 -1
  15. package/dist/index.d.ts +5 -5
  16. package/dist/index.js +548 -519
  17. package/dist/parsers/arrayParser.d.ts +4 -3
  18. package/dist/parsers/enumArrayParser.d.ts +3 -1
  19. package/dist/parsers/enumOptionsParser.d.ts +5 -0
  20. package/dist/parsers/index.d.ts +1 -0
  21. package/dist/parsers/intParser.d.ts +2 -4
  22. package/dist/parsers/objectParser.d.ts +4 -0
  23. package/dist/parsers/optionalParser.d.ts +4 -3
  24. package/dist/parsers/parserNestedDataUtils.d.ts +14 -0
  25. package/dist/parsers/parserUtils.d.ts +56 -0
  26. package/dist/parsers/parsers.d.ts +14 -80
  27. package/dist/stateHandling/index.d.ts +1 -1
  28. package/dist/stateHandling/stateNode.d.ts +123 -0
  29. package/dist/typeFactory/dataEntryTyping.d.ts +2 -2
  30. package/dist/types/arrayData.d.ts +3 -3
  31. package/dist/types/dataEntry.d.ts +45 -15
  32. package/dist/types/enumArrayData.d.ts +4 -1
  33. package/dist/types/enumData.d.ts +3 -1
  34. package/dist/types/enumOptionsData.d.ts +5 -3
  35. package/dist/types/index.d.ts +2 -1
  36. package/dist/types/objectData.d.ts +8 -0
  37. package/dist/types/optionalData.d.ts +4 -3
  38. package/dist/types/stateDataEntry.d.ts +10 -6
  39. package/dist/types/updateType.d.ts +16 -0
  40. package/dist/update/arrayUpdate.d.ts +4 -2
  41. package/dist/update/booleanUpdate.d.ts +3 -2
  42. package/dist/update/enumArrayUpdate.d.ts +3 -2
  43. package/dist/update/enumOptionsUpdate.d.ts +3 -2
  44. package/dist/update/enumUpdate.d.ts +2 -1
  45. package/dist/update/floatUpdate.d.ts +2 -1
  46. package/dist/update/index.d.ts +1 -0
  47. package/dist/update/intUpdate.d.ts +2 -1
  48. package/dist/update/objectUpdate.d.ts +2 -0
  49. package/dist/update/optionalUpdate.d.ts +3 -2
  50. package/dist/update/updateUtils.d.ts +27 -0
  51. package/dist/update/updateValues.d.ts +5 -4
  52. package/dist/update/validateUtils.d.ts +2 -0
  53. package/dist/update/versionUpdate.d.ts +3 -2
  54. package/dist/utils/interpolateData.d.ts +4 -1
  55. package/dist/utils/relativeValue.d.ts +4 -1
  56. package/package.json +2 -2
@@ -1,2 +1,3 @@
1
- import { EnumArrayDataEntry } from '@/types';
2
- export declare const updateValue: (original: EnumArrayDataEntry, update: EnumArrayDataEntry) => EnumArrayDataEntry;
1
+ import { EnumArrayDataEntry } from '../types';
2
+ export declare const constrainValue: <T extends EnumArrayDataEntry>(original: T, update: T["value"]) => T["value"];
3
+ export declare const updateValue: <T extends EnumArrayDataEntry>(original: T, update: T["value"]) => T;
@@ -1,2 +1,3 @@
1
- import { EnumOptionsDataEntry } from '@/types';
2
- export declare const updateComplexValue: (original: EnumOptionsDataEntry, update: EnumOptionsDataEntry) => EnumOptionsDataEntry;
1
+ import { EnumOptionsDataEntry, UpdateState } from '../types';
2
+ export declare const constrainState: (descriptorLength: EnumOptionsDataEntry["descriptor"]["length"], state: number) => number;
3
+ export declare const updateState: UpdateState<EnumOptionsDataEntry>;
@@ -1,2 +1,3 @@
1
1
  import { EnumDataEntry } from '../types/dataEntry';
2
- export declare const updateValue: (original: EnumDataEntry, update: EnumDataEntry) => EnumDataEntry;
2
+ export declare const constrainValue: <T extends EnumDataEntry>(original: T, update: T["value"]) => T["value"];
3
+ export declare const updateValue: <T extends EnumDataEntry>(original: T, update: T["value"]) => T;
@@ -1,2 +1,3 @@
1
1
  import { FloatDataEntry } from '../types/dataEntry';
2
- export declare const updateValue: (original: FloatDataEntry, update: FloatDataEntry) => FloatDataEntry;
2
+ export declare const constrainValue: <T extends FloatDataEntry>(original: T, update: T["value"]) => T["value"];
3
+ export declare const updateValue: <T extends FloatDataEntry>(original: T, update: T["value"]) => T;
@@ -1 +1,2 @@
1
1
  export * from './updateValues';
2
+ export * from './validateUtils';
@@ -1,2 +1,3 @@
1
1
  import { IntDataEntry } from '../types/dataEntry';
2
- export declare const updateValue: (original: IntDataEntry, update: IntDataEntry) => IntDataEntry;
2
+ export declare const constrainValue: <T extends IntDataEntry>(original: T, update: T["value"]) => T["value"];
3
+ export declare const updateValue: <T extends IntDataEntry>(original: T, update: T["value"]) => T;
@@ -0,0 +1,2 @@
1
+ import { ObjectDataEntry } from '../types';
2
+ export declare const updateValue: (original: ObjectDataEntry, value: ObjectDataEntry["value"]) => ObjectDataEntry;
@@ -1,2 +1,3 @@
1
- import { OptionalDataEntry } from '@/types';
2
- export declare const updateComplexValue: (original: OptionalDataEntry, update: OptionalDataEntry) => OptionalDataEntry;
1
+ import { OptionalDataEntry, UpdateState } from '../types';
2
+ export declare const constrainState: (state: OptionalDataEntry["state"]) => OptionalDataEntry["state"];
3
+ export declare const updateState: UpdateState<OptionalDataEntry>;
@@ -0,0 +1,27 @@
1
+ import { PrecisionRangeType } from '../types';
2
+ /**
3
+ * Get the step for a given precision
4
+ * @param precision - the precision range
5
+ */
6
+ export declare const getStepForPrecision: (precision: PrecisionRangeType) => number;
7
+ /**
8
+ * Constrain an unsigned int value to the given range
9
+ * @param value - the value to constrains
10
+ * @param maxValue - the maximum value (should be an integer)
11
+ */
12
+ export declare const constrainUnsignedInt: (value: number, maxValue: number) => number;
13
+ /**
14
+ * Constrain a signed int value to the given range
15
+ * @param value - the value to constrain
16
+ * @param minValue - the minimum value
17
+ * @param maxValue - the maximum value
18
+ */
19
+ export declare const constrainSignedInt: (value: number, minValue: number, maxValue: number) => number;
20
+ /**
21
+ * Constrain a float value to the given precision range
22
+ * @param value - the value to constrain
23
+ * @param minValue - the minimum value
24
+ * @param maxValue - the maximum value
25
+ * @param precision - the precision range
26
+ */
27
+ export declare const constrainFloat: (value: number, minValue: number, maxValue: number, precision: PrecisionRangeType) => number;
@@ -1,15 +1,16 @@
1
- import { DataEntry, ComplexDataEntry } from '../types/dataEntry';
1
+ import { UpdateWithStateEntries, UpdateWithValidationTypes, UpdateWithValuesEntries } from '../types';
2
2
  /**
3
3
  * Method to update the value of a data entry
4
+ * MUTATES OBJECT IN PLACE!
4
5
  * @param original - the original data entry
5
6
  * @param update - the update data entry
6
7
  * @returns the updated data entry
7
8
  */
8
- export declare const updateValue: (original: DataEntry, update: DataEntry) => DataEntry;
9
+ export declare const updateValueEntry: <T extends UpdateWithValuesEntries>(original: T, update: T["value"]) => T;
10
+ export declare const constrainValue: <T extends UpdateWithValidationTypes>(original: T, update: T["value"]) => T["value"];
9
11
  /**
10
12
  * Method to update the value of a data entry
11
13
  * @param original - the original data entry
12
14
  * @param update - the update data entry
13
- * @returns the updated data entry
14
15
  */
15
- export declare const updateComplexValue: (original: ComplexDataEntry, update: ComplexDataEntry) => ComplexDataEntry;
16
+ export declare const updateStateEntry: <T extends UpdateWithStateEntries>(original: T, update: T["state"]) => T;
@@ -0,0 +1,2 @@
1
+ import { DataEntry } from '../types';
2
+ export declare const validateDataEntry: <T extends DataEntry>(descriptorValue: T | null, differentValue: T | null) => T | null;
@@ -1,2 +1,3 @@
1
- import { VersionDataEntry } from '../types/dataEntry';
2
- export declare const updateValue: (original: VersionDataEntry, update: VersionDataEntry) => VersionDataEntry;
1
+ import { VersionDataEntry } from '../types';
2
+ export declare const constrainValue: <T extends VersionDataEntry>(original: T, update: T["value"]) => T["value"];
3
+ export declare const updateValue: <T extends VersionDataEntry>(original: T, update: T["value"]) => T;
@@ -1,3 +1,4 @@
1
+ import { ConstantBitWidthDataTypes } from '@/enums';
1
2
  import { DataEntry } from '../types/dataEntry';
2
3
  /**
3
4
  * helper method to interpolate a data entry at a given t parameter
@@ -5,4 +6,6 @@ import { DataEntry } from '../types/dataEntry';
5
6
  * @param t - number between 0 and 1
6
7
  * @returns updated data entry
7
8
  */
8
- export declare const interpolateEntryAt: (dataEntry: DataEntry, t: number) => DataEntry;
9
+ export declare const interpolateEntryAt: (dataEntry: DataEntry & {
10
+ type: (typeof ConstantBitWidthDataTypes)[number];
11
+ }, t: number) => DataEntry;
@@ -1,2 +1,5 @@
1
+ import { ConstantBitWidthDataTypes } from '@/enums';
1
2
  import { DataEntry } from '../types/dataEntry';
2
- export declare const getRelativeValue: (dataEntry: DataEntry) => number;
3
+ export declare const getRelativeValue: (dataEntry: DataEntry & {
4
+ type: (typeof ConstantBitWidthDataTypes)[number];
5
+ }) => Number;
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "dist/*"
7
7
  ],
8
8
  "type": "module",
9
- "version": "0.2.0",
9
+ "version": "0.3.0",
10
10
  "author": "Jonas Ward",
11
11
  "description": "Library for creating web safe base64 objects with custom bith widths and dynamic values.",
12
12
  "scripts": {
@@ -17,7 +17,7 @@
17
17
  "devDependencies": {
18
18
  "bun-types": "latest",
19
19
  "rimraf": "^6.0.1",
20
- "typescript": "^5.0.0",
20
+ "typescript": "^5.9.3",
21
21
  "@types/bun": "latest"
22
22
  }
23
23
  }