Skip to content

Commit 39c6d28

Browse files
author
Lars Kölpin-Freese
committed
chore: update ts build chain
1 parent be61f56 commit 39c6d28

File tree

8 files changed

+102
-65
lines changed

8 files changed

+102
-65
lines changed

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ example/
66
.vscode
77
.idea
88
*.spec.js
9-
src/
9+
src/

.travis.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

package-lock.json

Lines changed: 9 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
{
22
"name": "magic-bytes.js",
33
"version": "1.0.0",
4-
"main": "./dist/bundle.js",
5-
"module": "./dist/bundle.js",
4+
"main": "./dist/index.js",
5+
"module": "./dist/index.js",
66
"types": "./index.d.ts",
77
"scripts": {
8-
"build": "webpack -p && webpack -p --config webpack.config.browser.js",
9-
"prepublish": "npm run test && webpack -p",
108
"prettier": "prettier --write \"{src,__{tests,mocks}__}/**/*.{tsx,ts}\"",
119
"gen-tree": "ts-node ./src/create-snapshot.ts",
12-
"start": "babel-node example/node.js",
1310
"test": "jest",
14-
"format": "prettier --single-quote --trailing-comma es5 --write \"{src,__{tests,mocks}__}/**/*.js\"",
15-
"example:node": "babel-node ./example/node/node.js"
11+
"build": "tsc"
1612
},
1713
"repository": {
1814
"url": "https://github.com/LarsKoelpin/magic-bytes",
@@ -39,22 +35,13 @@
3935
"@babel/preset-typescript": "^7.15.0",
4036
"@types/jest": "^27.0.1",
4137
"@types/node": "^16.6.2",
42-
"babel-cli": "^6.26.0",
43-
"babel-core": "^6.26.0",
44-
"babel-loader": "^7.1.4",
45-
"babel-plugin-transform-object-rest-spread": "^6.26.0",
46-
"babel-preset-env": "^1.6.1",
47-
"babel-preset-flow": "^6.23.0",
4838
"jest": "^27.0.6",
4939
"prettier": "^1.19.1",
5040
"regenerator-runtime": "^0.11.1",
5141
"ts-jest": "^27.0.5",
52-
"typescript": "^4.3.5",
53-
"webpack": "^4.43.0",
54-
"webpack-cli": "^3.3.11"
42+
"typescript": "^4.3.5"
5543
},
5644
"dependencies": {
57-
"ts-node": "^10.2.1",
58-
"zod": "^3.7.3"
45+
"ts-node": "^10.2.1"
5946
}
6047
}

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ export const filetypeinfo = (bytes: number[]): GuessedFile[] => {
1010
if (offsetExceedsFile) {
1111
continue;
1212
}
13-
const node = patternTree.offset[k];
13+
const node: Node = (patternTree as any).offset[k];
14+
1415
const guessed = walkTree(offset, bytes, node);
1516
if (guessed.length > 0) {
1617
return guessed;
1718
}
1819
}
20+
if (tree.noOffset === null) {
21+
return [];
22+
}
1923
return walkTree(0, bytes, tree.noOffset);
2024
};
2125

src/model/tree.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { merge, createNode, createComplexNode } from "./tree";
22

33
describe("tree", () => {
44
it("Creates complex node", () => {
5-
const tree = createComplexNode("mpe", ["0x00", "0x01"]);
5+
const tree: any = createComplexNode("mpe", ["0x00", "0x01"]);
66
expect(tree.bytes["0x00"].bytes["0x01"]).toHaveProperty("matches");
77
expect(tree.bytes["0x00"].bytes["0x01"]["matches"][0].typename).toBe("mpe");
88
});
99

1010
it("Merges trees", () => {
1111
const tree = createComplexNode("pic", ["0x00"]);
1212
const dba = createNode("dba", ["0x00", "0x01", "0x02", "0x03"]);
13-
const merged = merge(dba, tree);
13+
const merged: any = merge(dba, tree);
1414
expect(merged.bytes["0x00"].matches[0].typename).toBe("pic");
1515
expect(
1616
merged.bytes["0x00"].bytes["0x01"].bytes["0x02"].bytes["0x03"].matches[0]
@@ -41,8 +41,8 @@ describe("tree", () => {
4141
["0x47", "0x49", "0x46", "0x38", "0x39", "0x61"],
4242
{ mime: "image/gif", extension: "gif" }
4343
);
44-
const mergeA = merge(gifB, gifA);
45-
const mergeB = merge(gifC, mergeA);
44+
const mergeA: any = merge(gifB, gifA);
45+
const mergeB: any = merge(gifC, mergeA);
4646
expect(
4747
mergeB.bytes["0x47"].bytes["0x49"].bytes["0x46"].bytes["0x38"].bytes[
4848
"0x37"

tsconfig.json

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"compilerOptions": {
3+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
4+
5+
/* Basic Options */
6+
// "incremental": true, /* Enable incremental compilation */
7+
"target": "ES2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */,
8+
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
9+
"lib": [
10+
"ES2020"
11+
] /* Specify library files to be included in the compilation. */,
12+
// "allowJs": true, /* Allow javascript files to be compiled. */
13+
// "checkJs": true, /* Report errors in .js files. */
14+
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
15+
"declaration": true /* Generates corresponding '.d.ts' file. */,
16+
"declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */,
17+
"sourceMap": false /* Generates corresponding '.map' file. */,
18+
// "outFile": "./", /* Concatenate and emit output to single file. */
19+
"outDir": "./dist" /* Redirect output structure to the directory. */,
20+
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
21+
// "composite": true, /* Enable project compilation */
22+
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
23+
// "removeComments": true, /* Do not emit comments to output. */
24+
// "noEmit": true, /* Do not emit outputs. */
25+
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
26+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
27+
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
28+
29+
/* Strict Type-Checking Options */
30+
"strict": true /* Enable all strict type-checking options. */,
31+
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
32+
// "strictNullChecks": true, /* Enable strict null checks. */
33+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
34+
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
35+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
36+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
37+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
38+
39+
/* Additional Checks */
40+
// "noUnusedLocals": true, /* Report errors on unused locals. */
41+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
42+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
43+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
44+
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
45+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
46+
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
47+
48+
/* Module Resolution Options */
49+
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
50+
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
51+
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
52+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
53+
// "typeRoots": [], /* List of folders to include type definitions from. */
54+
"types": [
55+
"node",
56+
"jest"
57+
] /* Type declaration files to be included in compilation. */,
58+
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
59+
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
60+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
61+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
62+
63+
/* Source Map Options */
64+
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
65+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
66+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
67+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
68+
69+
/* Experimental Options */
70+
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
71+
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
72+
73+
/* Advanced Options */
74+
"skipLibCheck": true /* Skip type checking of declaration files. */,
75+
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
76+
},
77+
"include": ["src/**/*"]
78+
}

0 commit comments

Comments
 (0)