url-safe-bitpacking 0.1.14 → 0.2.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 +9 -0
- package/dist/enums/dataTypes.d.ts +4 -8
- package/dist/factory/arrayFactory.d.ts +2 -0
- package/dist/factory/enumArrayFactory.d.ts +2 -0
- package/dist/factory/enumFactory.d.ts +1 -1
- package/dist/factory/enumOptionsFactory.d.ts +2 -0
- package/dist/factory/factory.d.ts +13 -0
- package/dist/factory/floatFactory.d.ts +9 -0
- package/dist/factory/helperMethod.d.ts +19 -0
- package/dist/factory/optionalFactory.d.ts +2 -0
- package/dist/factory/utils.d.ts +9 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +536 -306
- package/dist/parsers/arrayParser.d.ts +4 -0
- package/dist/parsers/enumArrayParser.d.ts +4 -0
- package/dist/parsers/enumOptionsFactory.d.ts +4 -0
- package/dist/parsers/intParser.d.ts +6 -0
- package/dist/parsers/optionalParser.d.ts +4 -0
- package/dist/parsers/parsers.d.ts +81 -13
- package/dist/stateHandling/index.d.ts +1 -0
- package/dist/stateHandling/stateData.d.ts +3 -0
- package/dist/stateHandling/stateDataObject.d.ts +15 -0
- package/dist/typeFactory/dataEntryTyping.d.ts +6 -0
- package/dist/typeFactory/index.d.ts +1 -0
- package/dist/typeFactory/stateDataTyping.d.ts +1 -0
- package/dist/types/arrayData.d.ts +10 -0
- package/dist/types/booleanData.d.ts +1 -2
- package/dist/types/dataEntry.d.ts +64 -6
- package/dist/types/enumArrayData.d.ts +20 -0
- package/dist/types/enumData.d.ts +8 -2
- package/dist/types/enumOptionsData.d.ts +8 -0
- package/dist/types/floatData.d.ts +10 -2
- package/dist/types/index.d.ts +7 -5
- package/dist/types/intData.d.ts +8 -2
- package/dist/types/optionalData.d.ts +7 -0
- package/dist/types/stateDataEntry.d.ts +16 -0
- package/dist/types/versionData.d.ts +1 -2
- package/dist/update/arrayUpdate.d.ts +2 -0
- package/dist/update/enumArrayUpdate.d.ts +2 -0
- package/dist/update/enumOptionsUpdate.d.ts +2 -0
- package/dist/update/nestedDataMatching.d.ts +2 -0
- package/dist/update/optionalUpdate.d.ts +2 -0
- package/dist/update/updateValues.d.ts +14 -1
- package/package.json +3 -2
- package/dist/objectmap/index.d.ts +0 -4
- package/dist/objectmap/stateDataModel.d.ts +0 -19
- package/dist/objectmap/stateValueHelperMethods.d.ts +0 -13
- package/dist/objectmap/userMethods.d.ts +0 -12
- package/dist/types/arrayDefinitions.d.ts +0 -10
- package/dist/types/semanticMapping.d.ts +0 -6
- package/dist/types/stateValueModel.d.ts +0 -33
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ Package for creating definitions of parametric models that can be stored as comp
|
|
|
13
13
|
| flattening and reading of the objects | ✓ | ✓ | ¿ |
|
|
14
14
|
| arrays (both bit-level as arrays of objects) | ½ | ½ | |
|
|
15
15
|
| utility to create StateValueType | | | |
|
|
16
|
+
| ability to migrate one version to another | | | |
|
|
16
17
|
|
|
17
18
|
## concept
|
|
18
19
|
|
|
@@ -54,6 +55,14 @@ Floating points work very much like the integer type, with the main difference t
|
|
|
54
55
|
DataEntryFactory.createFloat(20, 10, 200, -1, 'shapePreProcessingWarptotal');
|
|
55
56
|
```
|
|
56
57
|
|
|
58
|
+
### enum array
|
|
59
|
+
|
|
60
|
+
Enum arrays are a special type of arrays where integer values are intepreted as being values of a **specific base** to then be transformed to base 2. The base is derived from the delta of the max `and` the `min` value of the enums. Besides that, there is also a `minCount` and `maxCount` value (which can be the same value, but `minCount` is at least 1). This only offers a compression rate of upto 22% vis-a-vis an array of `IntDataEntry` (worst case its 0% percent, it never takes up more space), so sometimes questionable whether it makese sense to use ^^.
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
DataEntryFactory.createEnumArray([0, 1, 2], 0, 10, 3, 5, 'enumArrayA')
|
|
64
|
+
```
|
|
65
|
+
|
|
57
66
|
### version
|
|
58
67
|
|
|
59
68
|
There is also a Version object which is a special case of the enum data type and has a bitwidth of 4, 6, 8 or, 10 and always occupies the first bits of the bitarray.
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
INT = 3,
|
|
6
|
-
FLOAT = 4
|
|
7
|
-
}
|
|
8
|
-
export declare const getDataTypeName: (type: DataType) => string;
|
|
1
|
+
export declare const DataTypeValues: readonly ["VERSION", "BOOLEAN", "ENUM", "INT", "FLOAT", "ENUM_ARRAY"];
|
|
2
|
+
export declare const ComplexDataValues: readonly ["OPTIONAL", "ENUM_OPTIONS", "ARRAY"];
|
|
3
|
+
export type DataType = (typeof DataTypeValues)[number];
|
|
4
|
+
export type ComplexDataType = (typeof ComplexDataValues)[number];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { EnumDataEntry } from '../types';
|
|
2
|
-
export declare const create: (value: number,
|
|
2
|
+
export declare const create: (value: number, options: (string | number | object)[] | string | number, name?: string, index?: number) => EnumDataEntry;
|
|
@@ -3,10 +3,23 @@ import { create as createInt } from './intFactory';
|
|
|
3
3
|
import { create as createBoolean } from './booleanFactory';
|
|
4
4
|
import { create as createVersion } from './versionFactory';
|
|
5
5
|
import { create as createEnum } from './enumFactory';
|
|
6
|
+
import { create as createEnumArray } from './enumArrayFactory';
|
|
7
|
+
import { create as createOptional } from './optionalFactory';
|
|
8
|
+
import { create as createEnumOptions } from './enumOptionsFactory';
|
|
9
|
+
import { create as createArray } from './arrayFactory';
|
|
10
|
+
/**
|
|
11
|
+
* Record containing all the factory methods for the different data entry objects
|
|
12
|
+
*/
|
|
6
13
|
export declare const DataEntryFactory: {
|
|
7
14
|
createFloat: typeof createFloat;
|
|
8
15
|
createInt: typeof createInt;
|
|
9
16
|
createEnum: typeof createEnum;
|
|
10
17
|
createBoolean: typeof createBoolean;
|
|
11
18
|
createVersion: typeof createVersion;
|
|
19
|
+
createEnumArray: typeof createEnumArray;
|
|
20
|
+
};
|
|
21
|
+
export declare const ComplexDataEntryFactory: {
|
|
22
|
+
createOptional: typeof createOptional;
|
|
23
|
+
createEnumOptions: typeof createEnumOptions;
|
|
24
|
+
createArray: typeof createArray;
|
|
12
25
|
};
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import { FloatDataEntry } from '../types';
|
|
2
2
|
import { PrecisionRangeType } from '../types/floatData';
|
|
3
|
+
/**
|
|
4
|
+
* Method to create a float data entry
|
|
5
|
+
* @param value - `number` default value, should be between `min` and `max`
|
|
6
|
+
* @param min - `number` (default: 0), should be smaller than `max`
|
|
7
|
+
* @param max - `number` (default: 1), should be larger than `min`
|
|
8
|
+
* @param precision - `PrecisionRangeType` (default: 2 -> .01),
|
|
9
|
+
* @param name - `string`
|
|
10
|
+
* @param index - `number`
|
|
11
|
+
*/
|
|
3
12
|
export declare const create: (value: number, min?: number, max?: number, precision?: PrecisionRangeType, name?: string, index?: number) => FloatDataEntry;
|
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import { VersionRangeType } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Helper method to get the minimum bits required to store a given integer value
|
|
4
|
+
* @param number - `number` value to get the minimum bits for
|
|
5
|
+
* @param maxBits - `number` maximum bits allowed
|
|
6
|
+
*/
|
|
2
7
|
export declare const getBitsForIntegerNumber: (number: number, maxBits: number) => number;
|
|
8
|
+
/**
|
|
9
|
+
* Helper method to get the minimum bits required to store a given integer value
|
|
10
|
+
* @param v - `number` value to get the minimum bits for
|
|
11
|
+
*/
|
|
3
12
|
export declare const getMinimumBitsForInteger: (v: number) => number;
|
|
13
|
+
/**
|
|
14
|
+
* Helper method to get the version value range value for a given number
|
|
15
|
+
* @param v - `number` value to get the version value range value for
|
|
16
|
+
* @returns `VersionRangeType` the version value range value
|
|
17
|
+
*/
|
|
4
18
|
export declare const getVersionValueRangeValueForNumber: (v: number) => VersionRangeType;
|
|
19
|
+
/**
|
|
20
|
+
* Helper method to get the maximum integer value for a given bit count
|
|
21
|
+
* @param bitCount - `number` bit width to get the maximum integer value for
|
|
22
|
+
* @returns `number` the maximum integer value
|
|
23
|
+
*/
|
|
5
24
|
export declare const getMaxIntegerValueForGivenBitWidth: (bitCount: number) => number;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Method to get the max and mapping from the options
|
|
3
|
+
* @param options - `any[] | string | number` the options to get the max and mapping from
|
|
4
|
+
* @returns `{ max: number; mapping: any[] }` the max and mapping
|
|
5
|
+
*/
|
|
6
|
+
export declare const getOptionsFromEnumOptions: (options: (string | number | object)[] | string | number) => {
|
|
7
|
+
max: number;
|
|
8
|
+
mapping: (string | number | object)[];
|
|
9
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { DataType } from './enums';
|
|
2
|
-
export { DataEntryFactory } from './factory';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
export { DataType, DataTypeValues, ComplexDataType, ComplexDataValues } from './enums';
|
|
2
|
+
export { DataEntryFactory, ComplexDataEntryFactory } from './factory';
|
|
3
|
+
export { PrecisionRangeType, SignificandMaxBits, FloatDataEntry, IntegerMaxBits, IntDataEntry, EnumDataEntry, EnumArrayDataEntry, VersionRangeType, VersionDataEntry, BooleanDataEntry, DataEntry, ComplexDataEntry, NestedData, ProtectedAttributeNames, StateDescriptor, StateObject, StateDataObject, StateDataEntry, State, PROTECTED_ATTRIBUTE_NAMES } from './types';
|
|
4
|
+
export { parseBase64ToBits, getBitsCount, valueBitsParser, dataBitsParser, dataEntryBitstringParser, dataBitsStringifier, dataEntryCorrecting } from './parsers';
|
|
5
|
+
export { createStateDataObject, getInitialStateFromBase64 } from './stateHandling';
|
|
6
6
|
export { interpolateEntryAt, getRelativeValue } from './utils';
|