diff --git a/README.md b/README.md index 17405c6..8395acd 100644 --- a/README.md +++ b/README.md @@ -28,12 +28,12 @@ The actual binary structure looks like this: This structure is repeats for the number of files. # Browser -Collected only parts of this module that not use the `Deno` namespace and prepared as browser-compatible code to [`mod.universal.ts`](./mod.universal.ts). +Collected only parts of this module that not use the `Deno` namespace and prepared as browser-compatible pure JavaScript to [`mod.pure.ts`](./mod.pure.ts). You can use script from [esm.sh](https://esm.sh). ```ts -import {fetchExtend} from "https://esm.sh/gh/dojyorin/deno_simple_utility@version/mod.universal.ts?bundle&target=esnext"; +import {fetchExtend} from "https://esm.sh/gh/dojyorin/deno_simple_utility@version/mod.pure.ts?bundle&target=esnext"; ``` # API diff --git a/mod.pure.ts b/mod.pure.ts new file mode 100644 index 0000000..73a06af --- /dev/null +++ b/mod.pure.ts @@ -0,0 +1,13 @@ +export * from "./src/pure/base64.ts"; +export * from "./src/pure/byte.ts"; +export * from "./src/pure/crypto.ts"; +export * from "./src/pure/deep.ts"; +export * from "./src/pure/deflate.ts"; +export * from "./src/pure/fetch.ts"; +export * from "./src/pure/import.ts"; +export * from "./src/pure/minipack.ts"; +export * from "./src/pure/primitive.ts"; +export * from "./src/pure/stream.ts"; +export * from "./src/pure/text.ts"; +export * from "./src/pure/time.ts"; +export * from "./src/pure/worker.ts"; \ No newline at end of file diff --git a/mod.test.ts b/mod.test.ts index 49cb8b0..382779f 100644 --- a/mod.test.ts +++ b/mod.test.ts @@ -1,19 +1,20 @@ -import "./test/base64.test.ts"; -import "./test/byte.test.ts"; -import "./test/crypto.test.ts"; -import "./test/csv.deno.test.ts"; -import "./test/deep.test.ts"; -import "./test/deflate.test.ts"; -import "./test/fetch.test.ts"; -import "./test/import.test.ts"; -import "./test/json.deno.test.ts"; -import "./test/log.deno.test.ts"; -import "./test/minipack.test.ts"; -import "./test/path.deno.test.ts"; -import "./test/platform.deno.test.ts"; -import "./test/primitive.test.ts"; -import "./test/process.deno.test.ts"; -import "./test/stream.test.ts"; -import "./test/text.test.ts"; -import "./test/time.test.ts"; -import "./test/worker.test.ts"; \ No newline at end of file +import "./test/pure/base64.test.ts"; +import "./test/pure/byte.test.ts"; +import "./test/pure/crypto.test.ts"; +import "./test/pure/deep.test.ts"; +import "./test/pure/deflate.test.ts"; +import "./test/pure/fetch.test.ts"; +import "./test/pure/import.test.ts"; +import "./test/pure/primitive.test.ts"; +import "./test/pure/minipack.test.ts"; +import "./test/pure/stream.test.ts"; +import "./test/pure/text.test.ts"; +import "./test/pure/time.test.ts"; +import "./test/pure/worker.test.ts"; + +import "./test/deno/csv.test.ts"; +import "./test/deno/json.test.ts"; +import "./test/deno/log.test.ts"; +import "./test/deno/path.test.ts"; +import "./test/deno/platform.test.ts"; +import "./test/deno/process.test.ts"; \ No newline at end of file diff --git a/mod.ts b/mod.ts index 6282c95..132349e 100644 --- a/mod.ts +++ b/mod.ts @@ -1,20 +1,20 @@ -export * from "./src/base64.ts"; -export * from "./src/byte.ts"; -export * from "./src/crypto.ts"; -export * from "./src/deep.ts"; -export * from "./src/deflate.ts"; -export * from "./src/fetch.ts"; -export * from "./src/import.ts"; -export * from "./src/minipack.ts"; -export * from "./src/primitive.ts"; -export * from "./src/stream.ts"; -export * from "./src/text.ts"; -export * from "./src/time.ts"; -export * from "./src/worker.ts"; +export * from "./src/pure/base64.ts"; +export * from "./src/pure/byte.ts"; +export * from "./src/pure/crypto.ts"; +export * from "./src/pure/deep.ts"; +export * from "./src/pure/deflate.ts"; +export * from "./src/pure/fetch.ts"; +export * from "./src/pure/import.ts"; +export * from "./src/pure/minipack.ts"; +export * from "./src/pure/primitive.ts"; +export * from "./src/pure/stream.ts"; +export * from "./src/pure/text.ts"; +export * from "./src/pure/time.ts"; +export * from "./src/pure/worker.ts"; -export * from "./src/csv.deno.ts"; -export * from "./src/json.deno.ts"; -export * from "./src/log.deno.ts"; -export * from "./src/path.deno.ts"; -export * from "./src/platform.deno.ts"; -export * from "./src/process.deno.ts"; \ No newline at end of file +export * from "./src/deno/csv.ts"; +export * from "./src/deno/json.ts"; +export * from "./src/deno/log.ts"; +export * from "./src/deno/path.ts"; +export * from "./src/deno/platform.ts"; +export * from "./src/deno/process.ts"; \ No newline at end of file diff --git a/mod.universal.ts b/mod.universal.ts deleted file mode 100644 index 0cdb7b7..0000000 --- a/mod.universal.ts +++ /dev/null @@ -1,13 +0,0 @@ -export * from "./src/base64.ts"; -export * from "./src/byte.ts"; -export * from "./src/crypto.ts"; -export * from "./src/deep.ts"; -export * from "./src/deflate.ts"; -export * from "./src/fetch.ts"; -export * from "./src/import.ts"; -export * from "./src/minipack.ts"; -export * from "./src/primitive.ts"; -export * from "./src/stream.ts"; -export * from "./src/text.ts"; -export * from "./src/time.ts"; -export * from "./src/worker.ts"; \ No newline at end of file diff --git a/src/csv.deno.ts b/src/deno/csv.ts similarity index 89% rename from src/csv.deno.ts rename to src/deno/csv.ts index 3a6c738..380825d 100644 --- a/src/csv.deno.ts +++ b/src/deno/csv.ts @@ -1,6 +1,6 @@ -import {parse, stringify} from "../deps.ts"; -import {deepClone} from "./deep.ts"; -import {primitiveParseX} from "./primitive.ts"; +import {parse, stringify} from "../../deps.ts"; +import {deepClone} from "../pure/deep.ts"; +import {primitiveParseX} from "../pure/primitive.ts"; /** * Object containing string, number, or boolean. diff --git a/src/json.deno.ts b/src/deno/json.ts similarity index 96% rename from src/json.deno.ts rename to src/deno/json.ts index 0498193..232f475 100644 --- a/src/json.deno.ts +++ b/src/deno/json.ts @@ -1,4 +1,4 @@ -import {type Opt} from "./deep.ts"; +import {type Opt} from "../pure/deep.ts"; /** * Read JSON file and convert to object. diff --git a/src/log.deno.ts b/src/deno/log.ts similarity index 90% rename from src/log.deno.ts rename to src/deno/log.ts index 94a0abf..36da6af 100644 --- a/src/log.deno.ts +++ b/src/deno/log.ts @@ -1,5 +1,5 @@ -import {Logger, ConsoleHandler, FileHandler, format} from "../deps.ts"; -import {mainPath} from "./path.deno.ts"; +import {Logger, ConsoleHandler, FileHandler, format} from "../../deps.ts"; +import {mainPath} from "./path.ts"; function logRecord(date:Date, level:string, message:string){ return `${format(date, "yyyy-MM-ddTHH:mm:ss")} [${level}] ${message}`; diff --git a/src/path.deno.ts b/src/deno/path.ts similarity index 94% rename from src/path.deno.ts rename to src/deno/path.ts index 8fd8977..56759b6 100644 --- a/src/path.deno.ts +++ b/src/deno/path.ts @@ -1,5 +1,5 @@ -import {dirname, fromFileUrl} from "../deps.ts"; -import {isWin} from "./platform.deno.ts"; +import {dirname, fromFileUrl} from "../../deps.ts"; +import {isWin} from "./platform.ts"; /** * Convert from backslash to slash. diff --git a/src/platform.deno.ts b/src/deno/platform.ts similarity index 100% rename from src/platform.deno.ts rename to src/deno/platform.ts diff --git a/src/process.deno.ts b/src/deno/process.ts similarity index 100% rename from src/process.deno.ts rename to src/deno/process.ts diff --git a/src/base64.ts b/src/pure/base64.ts similarity index 100% rename from src/base64.ts rename to src/pure/base64.ts diff --git a/src/byte.ts b/src/pure/byte.ts similarity index 100% rename from src/byte.ts rename to src/pure/byte.ts diff --git a/src/crypto.ts b/src/pure/crypto.ts similarity index 100% rename from src/crypto.ts rename to src/pure/crypto.ts diff --git a/src/deep.ts b/src/pure/deep.ts similarity index 100% rename from src/deep.ts rename to src/pure/deep.ts diff --git a/src/deflate.ts b/src/pure/deflate.ts similarity index 100% rename from src/deflate.ts rename to src/pure/deflate.ts diff --git a/src/fetch.ts b/src/pure/fetch.ts similarity index 100% rename from src/fetch.ts rename to src/pure/fetch.ts diff --git a/src/import.ts b/src/pure/import.ts similarity index 100% rename from src/import.ts rename to src/pure/import.ts diff --git a/src/minipack.ts b/src/pure/minipack.ts similarity index 100% rename from src/minipack.ts rename to src/pure/minipack.ts diff --git a/src/primitive.ts b/src/pure/primitive.ts similarity index 100% rename from src/primitive.ts rename to src/pure/primitive.ts diff --git a/src/stream.ts b/src/pure/stream.ts similarity index 100% rename from src/stream.ts rename to src/pure/stream.ts diff --git a/src/text.ts b/src/pure/text.ts similarity index 100% rename from src/text.ts rename to src/pure/text.ts diff --git a/src/time.ts b/src/pure/time.ts similarity index 100% rename from src/time.ts rename to src/pure/time.ts diff --git a/src/worker.ts b/src/pure/worker.ts similarity index 100% rename from src/worker.ts rename to src/pure/worker.ts diff --git a/test/csv.deno.test.ts b/test/deno/csv.test.ts similarity index 78% rename from test/csv.deno.test.ts rename to test/deno/csv.test.ts index e2cab2b..2474c41 100644 --- a/test/csv.deno.test.ts +++ b/test/deno/csv.test.ts @@ -1,5 +1,5 @@ -import {assertEquals} from "../deps.test.ts"; -import {csvEncode, csvDecode} from "../src/csv.deno.ts"; +import {assertEquals} from "../../deps.test.ts"; +import {csvEncode, csvDecode} from "../../src/deno/csv.ts"; const sample = [{ foo: 123, diff --git a/test/json.deno.test.ts b/test/deno/json.test.ts similarity index 86% rename from test/json.deno.test.ts rename to test/deno/json.test.ts index 1292e03..680bd19 100644 --- a/test/json.deno.test.ts +++ b/test/deno/json.test.ts @@ -1,5 +1,5 @@ -import {assertEquals} from "../deps.test.ts"; -import {jsonRead, jsonWrite, jsonLoad} from "../src/json.deno.ts"; +import {assertEquals} from "../../deps.test.ts"; +import {jsonRead, jsonWrite, jsonLoad} from "../../src/deno/json.ts"; const object = { id: "22d8b040-8a63-46a0-8df6-0f508a778689", diff --git a/test/log.deno.test.ts b/test/deno/log.test.ts similarity index 78% rename from test/log.deno.test.ts rename to test/deno/log.test.ts index 9eb0d48..eb9ce26 100644 --- a/test/log.deno.test.ts +++ b/test/deno/log.test.ts @@ -1,5 +1,5 @@ -import {assertEquals, exists} from "../deps.test.ts"; -import {logEntry} from "../src/log.deno.ts"; +import {assertEquals, exists} from "../../deps.test.ts"; +import {logEntry} from "../../src/deno/log.ts"; const name = "operation"; diff --git a/test/path.deno.test.ts b/test/deno/path.test.ts similarity index 91% rename from test/path.deno.test.ts rename to test/deno/path.test.ts index 00ea448..7d6ce83 100644 --- a/test/path.deno.test.ts +++ b/test/deno/path.test.ts @@ -1,5 +1,5 @@ -import {assertEquals, dirname, fromFileUrl} from "../deps.test.ts"; -import {slashU, slashW, tmpPath, dataPath, homePath, mainPath} from "../src/path.deno.ts"; +import {assertEquals, dirname, fromFileUrl} from "../../deps.test.ts"; +import {slashU, slashW, tmpPath, dataPath, homePath, mainPath} from "../../src/deno/path.ts"; Deno.test({ name: "Path: Separator", diff --git a/test/platform.deno.test.ts b/test/deno/platform.test.ts similarity index 73% rename from test/platform.deno.test.ts rename to test/deno/platform.test.ts index cf1ff22..1ed56bd 100644 --- a/test/platform.deno.test.ts +++ b/test/deno/platform.test.ts @@ -1,5 +1,5 @@ -import {assertEquals} from "../deps.test.ts"; -import {isWin} from "../src/platform.deno.ts"; +import {assertEquals} from "../../deps.test.ts"; +import {isWin} from "../../src/deno/platform.ts"; Deno.test({ ignore: Deno.build.os !== "windows", diff --git a/test/process.deno.test.ts b/test/deno/process.test.ts similarity index 62% rename from test/process.deno.test.ts rename to test/deno/process.test.ts index 20a3719..98dabe0 100644 --- a/test/process.deno.test.ts +++ b/test/deno/process.test.ts @@ -1,5 +1,5 @@ -import {assertEquals} from "../deps.test.ts"; -import {runCommand} from "../src/process.deno.ts"; +import {assertEquals} from "../../deps.test.ts"; +import {runCommand} from "../../src/deno/process.ts"; Deno.test({ name: "Process: Run (no args)", diff --git a/test/base64.test.ts b/test/pure/base64.test.ts similarity index 86% rename from test/base64.test.ts rename to test/pure/base64.test.ts index 27a22df..41273d7 100644 --- a/test/base64.test.ts +++ b/test/pure/base64.test.ts @@ -1,5 +1,5 @@ -import {assertEquals} from "../deps.test.ts"; -import {b64Encode, b64Decode, b64DataURL} from "../src/base64.ts"; +import {assertEquals} from "../../deps.test.ts"; +import {b64Encode, b64Decode, b64DataURL} from "../../src/pure/base64.ts"; const sample1 = new Uint8Array([ 0x58, 0x0D, 0xC7, 0x64, 0x21, 0x42, 0x27, 0x76, diff --git a/test/byte.test.ts b/test/pure/byte.test.ts similarity index 78% rename from test/byte.test.ts rename to test/pure/byte.test.ts index c402741..b6b3328 100644 --- a/test/byte.test.ts +++ b/test/pure/byte.test.ts @@ -1,5 +1,5 @@ -import {assertEquals} from "../deps.test.ts"; -import {blobConvert, byteConcat} from "../src/byte.ts"; +import {assertEquals} from "../../deps.test.ts"; +import {blobConvert, byteConcat} from "../../src/pure/byte.ts"; const sample = "hello!"; diff --git a/test/crypto.test.ts b/test/pure/crypto.test.ts similarity index 93% rename from test/crypto.test.ts rename to test/pure/crypto.test.ts index da954ed..6ab381e 100644 --- a/test/crypto.test.ts +++ b/test/pure/crypto.test.ts @@ -1,5 +1,5 @@ -import {assertEquals} from "../deps.test.ts"; -import {generateRandom, deriveHash, pkGenerateECDH, pkGenerateECDSA, pkEncrypt, pkDecrypt, pkSign, pkVerify} from "../src/crypto.ts"; +import {assertEquals} from "../../deps.test.ts"; +import {generateRandom, deriveHash, pkGenerateECDH, pkGenerateECDSA, pkEncrypt, pkDecrypt, pkSign, pkVerify} from "../../src/pure/crypto.ts"; const sample = new Uint8Array([0x02, 0xF2, 0x5D, 0x1F, 0x1C, 0x34, 0xB9, 0x2F]); diff --git a/test/deep.test.ts b/test/pure/deep.test.ts similarity index 84% rename from test/deep.test.ts rename to test/pure/deep.test.ts index 8d64b40..07684cd 100644 --- a/test/deep.test.ts +++ b/test/pure/deep.test.ts @@ -1,5 +1,5 @@ -import {assertEquals} from "../deps.test.ts"; -import {deepClone, deepFreeze, deepSeal} from "../src/deep.ts"; +import {assertEquals} from "../../deps.test.ts"; +import {deepClone, deepFreeze, deepSeal} from "../../src/pure/deep.ts"; const sample = { aaa: { diff --git a/test/deflate.test.ts b/test/pure/deflate.test.ts similarity index 79% rename from test/deflate.test.ts rename to test/pure/deflate.test.ts index 7017344..ed5c386 100644 --- a/test/deflate.test.ts +++ b/test/pure/deflate.test.ts @@ -1,5 +1,5 @@ -import {assertEquals} from "../deps.test.ts"; -import {deflateEncode, deflateDecode} from "../src/deflate.ts"; +import {assertEquals} from "../../deps.test.ts"; +import {deflateEncode, deflateDecode} from "../../src/pure/deflate.ts"; const sample = new Uint8Array([ 0x71, 0xD6, 0xFB, 0x3D, 0xF9, 0xD9, 0x41, 0x07, diff --git a/test/fetch.test.ts b/test/pure/fetch.test.ts similarity index 85% rename from test/fetch.test.ts rename to test/pure/fetch.test.ts index 98badea..9bdaa98 100644 --- a/test/fetch.test.ts +++ b/test/pure/fetch.test.ts @@ -1,5 +1,5 @@ -import {assertEquals} from "../deps.test.ts"; -import {fetchExtend} from "../src/fetch.ts"; +import {assertEquals} from "../../deps.test.ts"; +import {fetchExtend} from "../../src/pure/fetch.ts"; const sample = new Uint8Array([ 0x71, 0xD6, 0xFB, 0x3D, 0xF9, 0xD9, 0x41, 0x07, diff --git a/test/import.test.ts b/test/pure/import.test.ts similarity index 67% rename from test/import.test.ts rename to test/pure/import.test.ts index 03d018a..e9a8930 100644 --- a/test/import.test.ts +++ b/test/pure/import.test.ts @@ -1,5 +1,5 @@ -import {assertEquals} from "../deps.test.ts"; -import {importAssert} from "../src/import.ts"; +import {assertEquals} from "../../deps.test.ts"; +import {importAssert} from "../../src/pure/import.ts"; const expect = { assert: { diff --git a/test/minipack.test.ts b/test/pure/minipack.test.ts similarity index 77% rename from test/minipack.test.ts rename to test/pure/minipack.test.ts index dfcd35c..8f5b25e 100644 --- a/test/minipack.test.ts +++ b/test/pure/minipack.test.ts @@ -1,5 +1,5 @@ -import {assertEquals} from "../deps.test.ts"; -import {mpEncode, mpDecode} from "../src/minipack.ts"; +import {assertEquals} from "../../deps.test.ts"; +import {mpEncode, mpDecode} from "../../src/pure/minipack.ts"; const sampleBin = new Uint8Array([0x02, 0xF2, 0x5D, 0x1F, 0x1C, 0x34, 0xB9, 0x2F]); const sampleName = "random.bin"; diff --git a/test/primitive.test.ts b/test/pure/primitive.test.ts similarity index 88% rename from test/primitive.test.ts rename to test/pure/primitive.test.ts index b2727e0..2349826 100644 --- a/test/primitive.test.ts +++ b/test/pure/primitive.test.ts @@ -1,5 +1,5 @@ -import {assertEquals} from "../deps.test.ts"; -import {primitiveParse, primitiveParseX} from "../src/primitive.ts"; +import {assertEquals} from "../../deps.test.ts"; +import {primitiveParse, primitiveParseX} from "../../src/pure/primitive.ts"; Deno.test({ name: "Primitive: Parse", diff --git a/test/stream.test.ts b/test/pure/stream.test.ts similarity index 79% rename from test/stream.test.ts rename to test/pure/stream.test.ts index 8cfb360..b263cdb 100644 --- a/test/stream.test.ts +++ b/test/pure/stream.test.ts @@ -1,5 +1,5 @@ -import {assertEquals} from "../deps.test.ts"; -import {streamEncode, streamDecode} from "../src/stream.ts"; +import {assertEquals} from "../../deps.test.ts"; +import {streamEncode, streamDecode} from "../../src/pure/stream.ts"; const sample = new Uint8Array([ 0x71, 0xD6, 0xFB, 0x3D, 0xF9, 0xD9, 0x41, 0x07, diff --git a/test/text.test.ts b/test/pure/text.test.ts similarity index 93% rename from test/text.test.ts rename to test/pure/text.test.ts index aa2b9c9..7deb100 100644 --- a/test/text.test.ts +++ b/test/pure/text.test.ts @@ -1,5 +1,5 @@ -import {assertEquals} from "../deps.test.ts"; -import {u8Encode, u8Decode, sjisDecode, hexEncode, hexDecode, trimExtend, fixWidth, cleanText, accurateSegment, pad0} from "../src/text.ts"; +import {assertEquals} from "../../deps.test.ts"; +import {u8Encode, u8Decode, sjisDecode, hexEncode, hexDecode, trimExtend, fixWidth, cleanText, accurateSegment, pad0} from "../../src/pure/text.ts"; const sampleText = " Lorem ipsum\r dolor sit \r\r amet. "; const sampleBin = new Uint8Array([ diff --git a/test/time.test.ts b/test/pure/time.test.ts similarity index 82% rename from test/time.test.ts rename to test/pure/time.test.ts index db16be3..4349584 100644 --- a/test/time.test.ts +++ b/test/pure/time.test.ts @@ -1,5 +1,5 @@ -import {assertEquals} from "../deps.test.ts"; -import {utEncode, utDecode, utParse, delay, dtSerial} from "../src/time.ts"; +import {assertEquals} from "../../deps.test.ts"; +import {utEncode, utDecode, utParse, delay, dtSerial} from "../../src/pure/time.ts"; const sample = new Date(2000, 0, 1, 0, 0, 0, 0); diff --git a/test/worker.test.ts b/test/pure/worker.test.ts similarity index 82% rename from test/worker.test.ts rename to test/pure/worker.test.ts index 7fbd9ef..ffbfb93 100644 --- a/test/worker.test.ts +++ b/test/pure/worker.test.ts @@ -1,5 +1,5 @@ -import {assertEquals} from "../deps.test.ts"; -import {createTask} from "../src/worker.ts"; +import {assertEquals} from "../../deps.test.ts"; +import {createTask} from "../../src/pure/worker.ts"; const sample1 = new Uint8Array([1, 2, 3, 4]); const sample2 = new Uint8Array([2, 4, 6, 8]);