url-safe-bitpacking 0.3.4 → 0.3.5
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
CHANGED
|
@@ -29,10 +29,10 @@ From a memory footprint perspective there are two types of attributes in an obje
|
|
|
29
29
|
| Predefined Bitwidth | **✓** | **✓** | **✓** | **✓** | **✓** | ✗ | ✗ | ✗ | ✗ | ✗ |
|
|
30
30
|
| Has State Bit | ✗ | ✗ | ✗ | ✗ | ✗ | **✓** | **✓** | **✓** | **✓** | ✗ |
|
|
31
31
|
| Min Bitwidth | `4` | `1` | `1` | `0` | `0` | `1` | – | – | – | – |
|
|
32
|
-
| Max Bitwidth | `10` | `1` | `
|
|
32
|
+
| Max Bitwidth | `10` | `1` | `8` | `10` | `21` | `8` | – | – | – | – |
|
|
33
33
|
| Min State Bitwidth | – | – | – | – | – | `0` | `1` | `1` | `0` | – |
|
|
34
34
|
| Max State Bitwidth | – | – | – | – | – | `10` | `1` | `10` | `10` | – |
|
|
35
|
-
| Max Available States | `1024` | `2` | `
|
|
35
|
+
| Max Available States | `1024` | `2` | `256` | `1024` | `2097152` | `1024 x 256` | `2` | `256` | `1024` | - |
|
|
36
36
|
| Has Mapping | ✗ | ✗ | **✓** | ✗ | ✗ | **✓** | ✗ | **✓** | ✗ | ✗ |
|
|
37
37
|
| Has Nested Objects | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | **✓** | **✓** | **✓** | **✓** |
|
|
38
38
|
| **UPDATING** | **VERSION** | **BOOLEAN** | **ENUM** | **INT** | **FLOAT** | **ENUM_ARRAY** | **OPTIONAL** | **ENUM_OPTIONS** | **ARRAY** | **OBJECT** |
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type EnumOptionsFactory = (descriptor: (
|
|
1
|
+
import { EnumOptionsDataEntry, EnumOptionsType, ObjectDataEntry } from '../types';
|
|
2
|
+
export type EnumOptionsFactory = (descriptor: (ObjectDataEntry | null)[], defaultState?: number, name?: string, options?: EnumOptionsType) => EnumOptionsDataEntry;
|
|
3
3
|
export declare const create: EnumOptionsFactory;
|
package/dist/index.js
CHANGED
|
@@ -929,6 +929,7 @@ var getObjectForDataEntries = (entries) => {
|
|
|
929
929
|
});
|
|
930
930
|
return object;
|
|
931
931
|
};
|
|
932
|
+
var getStringForDataEntries = (values) => Array.isArray(values) && values.every((v) => typeof v === "string" && v.length === 1) ? values.join("") : values;
|
|
932
933
|
var getStateData = (entry) => {
|
|
933
934
|
switch (entry.type) {
|
|
934
935
|
case "BOOLEAN":
|
|
@@ -939,7 +940,7 @@ var getStateData = (entry) => {
|
|
|
939
940
|
case "ENUM":
|
|
940
941
|
return entry.mapping[entry.value];
|
|
941
942
|
case "ENUM_ARRAY":
|
|
942
|
-
return entry.value.map((v) => entry.mapping[v]);
|
|
943
|
+
return getStringForDataEntries(entry.value.map((v) => entry.mapping[v]));
|
|
943
944
|
case "OPTIONAL":
|
|
944
945
|
return entry.value === null ? null : getStateData(entry.value);
|
|
945
946
|
case "ENUM_OPTIONS":
|
|
@@ -948,7 +949,7 @@ var getStateData = (entry) => {
|
|
|
948
949
|
switch (entry.value.type) {
|
|
949
950
|
case "OBJECT":
|
|
950
951
|
return {
|
|
951
|
-
...
|
|
952
|
+
...getObjectForDataEntries(entry.value.value),
|
|
952
953
|
state
|
|
953
954
|
};
|
|
954
955
|
default:
|
|
@@ -959,7 +960,7 @@ var getStateData = (entry) => {
|
|
|
959
960
|
case "OBJECT":
|
|
960
961
|
return getObjectForDataEntries(entry.value);
|
|
961
962
|
case "ARRAY":
|
|
962
|
-
return entry.value.map(
|
|
963
|
+
return getStringForDataEntries(entry.value.map(getStateData));
|
|
963
964
|
}
|
|
964
965
|
};
|
|
965
966
|
// src/utils/interpolateData.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ObjectDataEntry } from './dataEntry';
|
|
2
2
|
import { EnumMappingType } from './enumData';
|
|
3
3
|
export type EnumOptionsData = {
|
|
4
4
|
type: 'ENUM_OPTIONS';
|
|
5
5
|
stateBits: number;
|
|
6
6
|
state: number;
|
|
7
|
-
descriptor: (
|
|
7
|
+
descriptor: (ObjectDataEntry | null)[];
|
|
8
8
|
mapping: EnumMappingType;
|
|
9
|
-
value:
|
|
9
|
+
value: ObjectDataEntry | null;
|
|
10
10
|
};
|