-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sync.
- Loading branch information
Showing
28 changed files
with
270 additions
and
233 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
while [[ ${#} -ge 1 ]]; do | ||
if [[ -f ./${1}.json ]]; then | ||
yq -I 4 -o y ./${1}.json | head -c -1 > ./${1}.yaml | ||
fi | ||
|
||
shift | ||
done |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export {assertEquals} from "https://deno.land/std@0.198.0/assert/mod.ts"; | ||
export {dirname, fromFileUrl} from "https://deno.land/std@0.198.0/path/mod.ts"; | ||
export {exists} from "https://deno.land/std@0.198.0/fs/mod.ts"; | ||
export {assertEquals} from "https://deno.land/std@0.203.0/assert/mod.ts"; | ||
export {dirname, fromFileUrl} from "https://deno.land/std@0.203.0/path/mod.ts"; | ||
export {exists} from "https://deno.land/std@0.203.0/fs/mod.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export {dirname, fromFileUrl} from "https://deno.land/std@0.198.0/path/mod.ts"; | ||
export {Logger, handlers} from "https://deno.land/std@0.198.0/log/mod.ts"; | ||
export {format} from "https://deno.land/std@0.198.0/datetime/mod.ts"; | ||
export {dirname, fromFileUrl} from "https://deno.land/std@0.203.0/path/mod.ts"; | ||
export {Logger, handlers} from "https://deno.land/std@0.203.0/log/mod.ts"; | ||
export {format} from "https://deno.land/std@0.203.0/datetime/mod.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import {b64Encode} from "./base64.ts"; | ||
|
||
/** | ||
* Assignment of types convertible from blob. | ||
*/ | ||
export interface BlobType{ | ||
"text": string; | ||
"base64": string; | ||
"byte": Uint8Array; | ||
"buffer": ArrayBuffer; | ||
} | ||
|
||
/** | ||
* Convert from blob to specified data type. | ||
* @example | ||
* ```ts | ||
* const file = new File(["my-text"], "example.txt"); | ||
* const data = await blobConvert(file, "text"); | ||
* ``` | ||
*/ | ||
export async function blobConvert<T extends keyof BlobType>(blob:Blob, type:T):Promise<BlobType[T]>{ | ||
switch(type){ | ||
case "text": return <BlobType[T]>await blob.text(); | ||
case "base64": return <BlobType[T]>b64Encode(new Uint8Array(await blob.arrayBuffer())); | ||
case "byte": return <BlobType[T]>new Uint8Array(await blob.arrayBuffer()); | ||
case "buffer": return <BlobType[T]>await blob.arrayBuffer(); | ||
default: throw new Error(); | ||
} | ||
} | ||
|
||
/** | ||
* Concat multiple buffer sources into single Uint8Array. | ||
* @example | ||
* ```ts | ||
* const byte = byteConcat(new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6])); | ||
* ``` | ||
*/ | ||
export function byteConcat(...parts:BufferSource[]):Uint8Array{ | ||
const output = new Uint8Array(parts.reduce((n, {byteLength}) => n + byteLength , 0)); | ||
let i = 0; | ||
|
||
for(const part of parts){ | ||
output.set(new Uint8Array(part instanceof ArrayBuffer ? part : part.buffer), i); | ||
i += part.byteLength; | ||
} | ||
|
||
return output; | ||
} |
Oops, something went wrong.