structurae
Advanced tools
Comparing version 0.0.28 to 1.0.0
@@ -173,5 +173,8 @@ // Type definitions for structurae | ||
type RecordFieldType = 'Int8' | 'Uint8' | 'Int16' | 'Uint16' | 'Int32' | 'Uint32' | ||
| 'Float32' | 'Float64' | 'BigInt64' | 'BigUint64' | 'String'; | ||
interface RecordField { | ||
name: string; | ||
type: string; | ||
type: RecordFieldType; | ||
size?: number; | ||
@@ -178,0 +181,0 @@ littleEndian?: boolean; |
/** | ||
* @typedef {('Int8' | 'Uint8' | 'Int16' | 'Uint16' | ||
* | 'Int32' | 'Uint32' | 'Float32' | 'Float64' | ||
* | 'BigInt64' | 'BigUint64' | 'String' )} RecordFieldType | ||
*/ | ||
/** | ||
* @typedef {Object} RecordField | ||
* @property {string} name | ||
* @property {string} type | ||
* @property {RecordFieldType} type | ||
* @property {number} [size] the maximum size in bytes for a string type | ||
@@ -58,3 +64,7 @@ * @property {boolean} [littleEndian] | ||
const field = fields[i]; | ||
if (field.type === 'String') hasString = true; | ||
if (field.type === 'String') { | ||
hasString = true; | ||
} else if (!Reflect.has(FieldSizes, field.type)) { | ||
throw TypeError(`Type "${field.type}" is not a valid type.`); | ||
} | ||
offsets[field.name] = lastOffset; | ||
@@ -81,5 +91,5 @@ schema[field.name] = field; | ||
/** | ||
* Returns the value of a given field of a struct at the given index. | ||
* Returns the value of a given field of a record at the given index. | ||
* | ||
* @param {number} index the index of a struct | ||
* @param {number} index the index of a record | ||
* @param {string} field the name of the field | ||
@@ -119,12 +129,11 @@ * @returns {*} value of the field | ||
return this.getBigUint64(offset, littleEndian); | ||
case 'String': | ||
default: | ||
return this.getString(offset, size); | ||
} | ||
return 0; | ||
} | ||
/** | ||
* Sets a value to a field of a struct at a given index. | ||
* Sets a value to a field of a record at a given index. | ||
* | ||
* @param {number} index the index of a struct | ||
* @param {number} index the index of a record | ||
* @param {string} field the name of the field | ||
@@ -177,3 +186,3 @@ * @param {*} value the value to be set | ||
break; | ||
case 'String': | ||
default: | ||
this.setString(offset, value, size); | ||
@@ -228,3 +237,3 @@ break; | ||
* | ||
* @param {number} index the index of the struct | ||
* @param {number} index the index of the record | ||
* @param {string} field the name of the field | ||
@@ -239,5 +248,5 @@ * @returns {number} the byte offset | ||
/** | ||
* The object representation of a given struct. | ||
* The object representation of a given record. | ||
* | ||
* @param {number} index the index of the struct | ||
* @param {number} index the index of the record | ||
* @returns {Object} | ||
@@ -244,0 +253,0 @@ * @example |
@@ -84,3 +84,4 @@ /** | ||
* @param {*} end the ending element | ||
* @param {boolean} [subarray=false] return a subarray instead of copying resulting value with slice | ||
* @param {boolean} [subarray=false] return a subarray | ||
* instead of copying resulting value with slice | ||
* @returns {SortedCollection} the resulting range of elements | ||
@@ -149,4 +150,5 @@ * @example | ||
/** | ||
* Returns the difference of two sorted arrays, i.e. elements present in the first array but not | ||
* in the second array. If `symmetric=true` finds the symmetric difference of two arrays, that is, | ||
* Returns the difference of two sorted arrays, | ||
* i.e. elements present in the first array but not in the second array. | ||
* If `symmetric=true` finds the symmetric difference of two arrays, that is, | ||
* the elements that are absent in one or another array. | ||
@@ -153,0 +155,0 @@ * |
@@ -133,2 +133,4 @@ const Encoder = new TextEncoder(); | ||
break; | ||
default: | ||
break; | ||
} | ||
@@ -301,2 +303,3 @@ } | ||
* Creates a StringView from a string. | ||
* todo use TextEncoder.encodeInto when supported by Node.js (FF supports already) | ||
* | ||
@@ -303,0 +306,0 @@ * @param {string} string the string to encode |
@@ -12,3 +12,4 @@ /** | ||
/** | ||
* A grid to handle symmetric or triangular matrices using half the space required for a normal grid. | ||
* A grid to handle symmetric or triangular matrices | ||
* using half the space required for a normal grid. | ||
* | ||
@@ -15,0 +16,0 @@ * @extends CollectionConstructor |
{ | ||
"name": "structurae", | ||
"version": "0.0.28", | ||
"version": "1.0.0", | ||
"description": "Data structures for performance-sensitive modern JavaScript applications.", | ||
@@ -48,9 +48,9 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@types/jest": "^24.0.9", | ||
"@types/jest": "^24.0.11", | ||
"benchmark": "^2.1.4", | ||
"codecov": "^3.2.0", | ||
"eslint": "^5.15.1", | ||
"codecov": "^3.3.0", | ||
"eslint": "^5.16.0", | ||
"eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-plugin-import": "^2.16.0", | ||
"jest": "^24.3.0", | ||
"eslint-plugin-import": "^2.17.2", | ||
"jest": "^24.7.1", | ||
"jsdoc-to-markdown": "^4.0.1" | ||
@@ -57,0 +57,0 @@ }, |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
149478
4121
0