mirror of
https://github.com/jwetzell/osc-js.git
synced 2026-08-21 06:49:02 +00:00
remove fromString methods
This commit is contained in:
@@ -11,6 +11,5 @@ export type OSCMessage = {
|
|||||||
|
|
||||||
export type OSCTypeConverter = {
|
export type OSCTypeConverter = {
|
||||||
toBuffer: (value: string | number | Buffer | boolean) => Buffer | undefined;
|
toBuffer: (value: string | number | Buffer | boolean) => Buffer | undefined;
|
||||||
fromString: (string: string) => string | number | Buffer | boolean;
|
|
||||||
fromBuffer: (buffer: Buffer) => [string | number | Buffer | boolean | undefined, Buffer];
|
fromBuffer: (buffer: Buffer) => [string | number | Buffer | boolean | undefined, Buffer];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ const oscTypeConverterMap: { [key: string]: OSCTypeConverter } = {
|
|||||||
}
|
}
|
||||||
throw new TypeError('osc type s toBuffer called with non string value');
|
throw new TypeError('osc type s toBuffer called with non string value');
|
||||||
},
|
},
|
||||||
fromString: (string: string) => string,
|
|
||||||
fromBuffer: (bytes: Buffer) => {
|
fromBuffer: (bytes: Buffer) => {
|
||||||
let stringEnd = 0;
|
let stringEnd = 0;
|
||||||
let stringPaddingEnd = 0;
|
let stringPaddingEnd = 0;
|
||||||
@@ -42,7 +41,6 @@ const oscTypeConverterMap: { [key: string]: OSCTypeConverter } = {
|
|||||||
}
|
}
|
||||||
throw new TypeError('osc type f toBuffer called with non number value');
|
throw new TypeError('osc type f toBuffer called with non number value');
|
||||||
},
|
},
|
||||||
fromString: (string: string) => Number.parseFloat(string),
|
|
||||||
fromBuffer: (buffer) => {
|
fromBuffer: (buffer) => {
|
||||||
if (buffer.length < 4) {
|
if (buffer.length < 4) {
|
||||||
throw new Error('not enough bytes to read a osc float');
|
throw new Error('not enough bytes to read a osc float');
|
||||||
@@ -61,7 +59,6 @@ const oscTypeConverterMap: { [key: string]: OSCTypeConverter } = {
|
|||||||
}
|
}
|
||||||
throw new TypeError('osc type i toBuffer called with non number value');
|
throw new TypeError('osc type i toBuffer called with non number value');
|
||||||
},
|
},
|
||||||
fromString: (string: string) => Number.parseInt(string, 10),
|
|
||||||
fromBuffer: (buffer) => {
|
fromBuffer: (buffer) => {
|
||||||
if (buffer.length < 4) {
|
if (buffer.length < 4) {
|
||||||
throw new Error('not enough bytes to read a osc integer');
|
throw new Error('not enough bytes to read a osc integer');
|
||||||
@@ -83,7 +80,6 @@ const oscTypeConverterMap: { [key: string]: OSCTypeConverter } = {
|
|||||||
}
|
}
|
||||||
throw new TypeError('osc type b toBuffer called with non Buffer value');
|
throw new TypeError('osc type b toBuffer called with non Buffer value');
|
||||||
},
|
},
|
||||||
fromString: (string: string) => Buffer.from(string, 'hex'),
|
|
||||||
fromBuffer: (buffer) => {
|
fromBuffer: (buffer) => {
|
||||||
const [blobLength, blobBytes] = oscTypeConverterMap.i.fromBuffer(buffer);
|
const [blobLength, blobBytes] = oscTypeConverterMap.i.fromBuffer(buffer);
|
||||||
if (typeof blobLength === 'number') {
|
if (typeof blobLength === 'number') {
|
||||||
@@ -103,7 +99,6 @@ const oscTypeConverterMap: { [key: string]: OSCTypeConverter } = {
|
|||||||
toBuffer: () => {
|
toBuffer: () => {
|
||||||
return Buffer.alloc(0);
|
return Buffer.alloc(0);
|
||||||
},
|
},
|
||||||
fromString: (string: string) => true,
|
|
||||||
fromBuffer: (buffer) => {
|
fromBuffer: (buffer) => {
|
||||||
return [true, buffer];
|
return [true, buffer];
|
||||||
},
|
},
|
||||||
@@ -112,7 +107,6 @@ const oscTypeConverterMap: { [key: string]: OSCTypeConverter } = {
|
|||||||
toBuffer: () => {
|
toBuffer: () => {
|
||||||
return Buffer.alloc(0);
|
return Buffer.alloc(0);
|
||||||
},
|
},
|
||||||
fromString: (string: string) => false,
|
|
||||||
fromBuffer: (buffer) => {
|
fromBuffer: (buffer) => {
|
||||||
return [false, buffer];
|
return [false, buffer];
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user