Skip to content

Commit

Permalink
Convert to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
atesgoral committed Aug 7, 2021
1 parent 13a1e57 commit b4ea4ac
Show file tree
Hide file tree
Showing 12 changed files with 347 additions and 193 deletions.
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
],
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
Expand All @@ -36,6 +37,11 @@
"stream-parser": "^0.3.1"
},
"devDependencies": {
"rollup": "^2.56.0"
"@rollup/plugin-typescript": "^8.2.5",
"@tsconfig/node12": "^1.0.9",
"@types/node": "^16.4.13",
"rollup": "^2.56.0",
"tslib": "^2.3.0",
"typescript": "^4.3.5"
}
}
11 changes: 7 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import {defineConfig} from 'rollup';
import typescript from '@rollup/plugin-typescript';
import pkg from './package.json';

export default {
input: 'src/index.js',
external: ['stream-parser'],
export default defineConfig({
input: 'src/index.ts',
external: ['stream-parser', 'stream'],
plugins: [typescript({tsconfig: './tsconfig.json'})],
output: [
{ file: pkg.main, format: 'cjs' },
{ file: pkg.module, format: 'es' }
]
};
});
2 changes: 0 additions & 2 deletions src/index.js

This file was deleted.

3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export {AcbStreamDecoder} from './lib/decoder';
export {encodeAcb} from './lib/encoder';
export type {ColorSpace, Color, ColorBook} from './lib/types';
23 changes: 23 additions & 0 deletions src/lib/chunk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export function fromAscii(value: string) {
return Buffer.from(value, 'ascii');
}

export function fromUInt16BE(value: number) {
const chunk = Buffer.allocUnsafe(2);
chunk.writeUInt16BE(value);
return chunk;
}

export function fromUInt32BE(value: number) {
const chunk = Buffer.allocUnsafe(4);
chunk.writeUInt32BE(value);
return chunk;
}

export function fromString(value: string) {
const chunk = Buffer.allocUnsafe(4 + value.length * 2);
chunk.write(value, 4, 'utf16le');
chunk.swap16();
chunk.writeUInt32BE(value.length);
return chunk;
}
160 changes: 0 additions & 160 deletions src/lib/decoder.js

This file was deleted.

Loading

0 comments on commit b4ea4ac

Please sign in to comment.