Skip to content

Commit

Permalink
Fixed require
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed Sep 20, 2023
1 parent ebafba6 commit ee71523
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "2.0.0",
"description": "A filesystem in your browser!",
"main": "dist/browserfs.js",
"typings": "dist/browserfs",
"types": "dist",
"keywords": [
"filesystem",
"node",
Expand All @@ -28,14 +28,14 @@
"url": "https://github.com/jvilk/BrowserFS/issues"
},
"engines": {
"node": ">= 0.10"
"node": ">= 14"
},
"bin": {
"make_http_index": "./dist/scripts/make_http_index.js"
},
"exports": {
".": {
"require": "./dist/browserfs.min.js",
"require": "./dist/browserfs.min.cjs",
"import": "./dist/browserfs.min.mjs"
}
},
Expand Down Expand Up @@ -76,4 +76,4 @@
"typedoc": "^0.25.1",
"typescript": "^4.9.5"
}
}
}
12 changes: 6 additions & 6 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { polyfillNode } from 'esbuild-plugin-polyfill-node';
const common = {
entryPoints: ['src/core/browserfs.ts'],
target: ['es6'],
platform: 'browser',
globalName: 'BrowserFS',
sourcemap: true,
bundle: true,
Expand All @@ -13,11 +12,12 @@ const common = {
};

const configs = {
'browser, unminified': { outfile: 'dist/browserfs.js' },
'browser, minified': { outfile: 'dist/browserfs.min.js', minify: true },
'ESM, unminified': { outfile: 'dist/browserfs.mjs', format: 'esm' },
'ESM, minified': { outfile: 'dist/browserfs.min.mjs', format: 'esm', minify: true },
node: { outfile: 'dist/browserfs.cjs', platform: 'node', format: 'cjs', minify: true, alias: {}, plugins: [] },
'browser, unminified': { outfile: 'dist/browserfs.js', platform: 'browser' },
'browser, minified': { outfile: 'dist/browserfs.min.js', platform: 'browser', minify: true },
'ESM, unminified': { outfile: 'dist/browserfs.mjs', platform: 'neutral', format: 'esm' },
'ESM, minified': { outfile: 'dist/browserfs.min.mjs', platform: 'neutral', format: 'esm', minify: true },
'node, unminified': { outfile: 'dist/browserfs.cjs', platform: 'node', format: 'cjs', alias: {}, plugins: [] },
'node, minified': { outfile: 'dist/browserfs.min.cjs', platform: 'node', format: 'cjs', minify: true, alias: {}, plugins: [] },
};

for (const [name, config] of Object.entries(configs)) {
Expand Down
9 changes: 4 additions & 5 deletions src/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function bufferValidator(v: object): Promise<void> {
*/

function _min(d0: number, d1: number, d2: number, bx: number, ay: number): number {
return d0 < d1 || d2 < d1 ? (d0 > d2 ? d2 + 1 : d0 + 1) : bx === ay ? d1 : d1 + 1;
return Math.min(d0 + 1, d1 + 1, d2 + 1, bx === ay ? d1 : d1 + 1);
}

/**
Expand All @@ -65,21 +65,21 @@ function levenshtein(a: string, b: string): number {
}

if (a.length > b.length) {
const tmp = a;
a = b;
b = tmp;
[a, b] = [b, a]; // Swap a and b
}

let la = a.length;
let lb = b.length;

// Trim common suffix
while (la > 0 && a.charCodeAt(la - 1) === b.charCodeAt(lb - 1)) {
la--;
lb--;
}

let offset = 0;

// Trim common prefix
while (offset < la && a.charCodeAt(offset) === b.charCodeAt(offset)) {
offset++;
}
Expand Down Expand Up @@ -138,7 +138,6 @@ function levenshtein(a: string, b: string): number {
return dd;
}


/**
* Checks that the given options object is valid for the file system options.
* @hidden
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,6 @@ export function getFileSystem(config: FileSystemConfiguration, cb?: BFSCallback<

export * from './core/backends';
export * from './core/ApiError';
export * from './generic/key_value_filesystem';
export * from './generic/inode';
export { EmscriptenFS, FileSystem, BaseFileSystem };
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"compilerOptions": {
"module": "es2015",
"target": "es2015",
"outDir": "build/temp/library/ts",
"outDir": "dist",
"lib": ["dom", "esnext"],
"moduleResolution": "node",
"sourceMap": true,
"inlineSources": true,
"declaration": true,
"emitDeclarationOnly": true,
"typeRoots": ["node_modules/@types"]
},
"include": ["src/**/*"]
Expand Down

0 comments on commit ee71523

Please sign in to comment.