BREAKING CHANGE(core): switch to esm

This commit is contained in:
Philipp Kunz 2022-03-24 13:12:59 +01:00
parent 7d263b2404
commit 56cb1eeffb
4 changed files with 14646 additions and 7815 deletions

22440
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,7 @@
"description": "a hash package that works cross environment", "description": "a hash package that works cross environment",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
"type": "module",
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
@ -12,16 +13,16 @@
"build": "(tsbuild --web)" "build": "(tsbuild --web)"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.0.22", "@gitzone/tsbuild": "^2.1.60",
"@gitzone/tstest": "^1.0.48", "@gitzone/tstest": "^1.0.69",
"@pushrocks/tapbundle": "^3.0.7", "@pushrocks/tapbundle": "^5.0.2",
"@types/node": "^14.11.2", "@types/node": "^17.0.23",
"tslint": "^6.1.3", "tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0" "tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/smartenv": "^4.0.11", "@pushrocks/smartenv": "^5.0.0",
"@pushrocks/smarthash": "^2.1.6" "@pushrocks/smarthash": "^2.1.10"
}, },
"browserslist": [ "browserslist": [
"last 1 chrome versions" "last 1 chrome versions"

View File

@ -1,11 +1,11 @@
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@pushrocks/tapbundle';
import * as isohash from '../ts/index'; import * as isohash from '../ts/index.js';
tap.test('first test', async () => { tap.test('first test', async () => {
const compareHash = 'f94b840e404ef088fd378ad3811e36357ab6ee39020bfbe48c8bf11b65d100dc'; const compareHash = 'f94b840e404ef088fd378ad3811e36357ab6ee39020bfbe48c8bf11b65d100dc';
const originString = 'eruzw873zrhchkjhdfuezrw'; const originString = 'eruzw873zrhchkjhdfuezrw';
const hashResult = await isohash.sha256FromString(originString); const hashResult = await isohash.sha256FromString(originString);
expect(hashResult).to.equal(compareHash); expect(hashResult).toEqual(compareHash);
console.log(hashResult); console.log(hashResult);
}); });

View File

@ -1,4 +1,4 @@
import * as plugins from './isohash.plugins'; import * as plugins from './isohash.plugins.js';
const hex = (buffer: ArrayBuffer) => { const hex = (buffer: ArrayBuffer) => {
const hexCodes = []; const hexCodes = [];
@ -30,7 +30,7 @@ export const sha256FromString = async (stringArg: string): Promise<string> => {
const result = hex(hash); const result = hex(hash);
return result; return result;
} else if (smartenv.isNode) { } else if (smartenv.isNode) {
const smarthashModule = smartenv.getSafeNodeModule('@pushrocks/smarthash'); const smarthashModule = await smartenv.getSafeNodeModule('@pushrocks/smarthash');
const result = await smarthashModule.sha256FromString(stringArg); const result = await smarthashModule.sha256FromString(stringArg);
return result; return result;
} }