run npm install to generate a package lock
This commit is contained in:
10
node_modules/node-buffer-encoding/.editorconfig
generated
vendored
Normal file
10
node_modules/node-buffer-encoding/.editorconfig
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
9
node_modules/node-buffer-encoding/dist/index.d.ts
generated
vendored
Normal file
9
node_modules/node-buffer-encoding/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { Encoding } from './types';
|
||||
declare const BufferEncoding: {
|
||||
encode: (data: Uint8Array, encoding: Encoding) => string;
|
||||
encodeStr: (data: string, encoding: Encoding) => string;
|
||||
decode: (data: string, encoding: Encoding) => Uint8Array;
|
||||
decodeStr: (data: string, encoding: Encoding) => string;
|
||||
};
|
||||
export default BufferEncoding;
|
||||
export type { Encoding };
|
||||
21
node_modules/node-buffer-encoding/dist/index.js
generated
vendored
Normal file
21
node_modules/node-buffer-encoding/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/* IMPORT */
|
||||
import { Buffer } from 'node:buffer';
|
||||
/* MAIN */
|
||||
const BufferEncoding = {
|
||||
/* API */
|
||||
encode: (data, encoding) => {
|
||||
return Buffer.from(data).toString(encoding);
|
||||
},
|
||||
encodeStr: (data, encoding) => {
|
||||
return Buffer.from(data).toString(encoding);
|
||||
},
|
||||
decode: (data, encoding) => {
|
||||
const buffer = Buffer.from(data, encoding);
|
||||
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
||||
},
|
||||
decodeStr: (data, encoding) => {
|
||||
return Buffer.from(data, encoding).toString();
|
||||
}
|
||||
};
|
||||
/* EXPORT */
|
||||
export default BufferEncoding;
|
||||
2
node_modules/node-buffer-encoding/dist/types.d.ts
generated
vendored
Normal file
2
node_modules/node-buffer-encoding/dist/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
type Encoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex';
|
||||
export type { Encoding };
|
||||
2
node_modules/node-buffer-encoding/dist/types.js
generated
vendored
Normal file
2
node_modules/node-buffer-encoding/dist/types.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/* MAIN */
|
||||
export {};
|
||||
21
node_modules/node-buffer-encoding/license
generated
vendored
Normal file
21
node_modules/node-buffer-encoding/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2022-present Fabio Spampinato
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
29
node_modules/node-buffer-encoding/package.json
generated
vendored
Executable file
29
node_modules/node-buffer-encoding/package.json
generated
vendored
Executable file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "node-buffer-encoding",
|
||||
"repository": "github:fabiospampinato/node-buffer-encoding",
|
||||
"description": "A little wrapper around Node's Buffer that provides encoding/decoding for all supported encodings.",
|
||||
"version": "1.0.2",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"exports": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"clean": "tsex clean",
|
||||
"compile": "tsex compile",
|
||||
"compile:watch": "tsex compile --watch",
|
||||
"test": "tsex test",
|
||||
"test:watch": "tsex test --watch",
|
||||
"prepublishOnly": "tsex prepare"
|
||||
},
|
||||
"keywords": [
|
||||
"node",
|
||||
"buffer",
|
||||
"encoding"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.4.7",
|
||||
"fava": "^0.2.1",
|
||||
"tsex": "^3.0.1",
|
||||
"typescript": "^5.1.6"
|
||||
}
|
||||
}
|
||||
33
node_modules/node-buffer-encoding/readme.md
generated
vendored
Normal file
33
node_modules/node-buffer-encoding/readme.md
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
# Node Buffer Encoding
|
||||
|
||||
A little wrapper around Node's Buffer that provides encoding/decoding for all supported encodings.
|
||||
|
||||
If you have access to Node's Buffer you probably just want to use it directly instead. This module provides a unified API to some of my other modules, and allows me not to import "@types/node" everywhere.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install --save node-buffer-encoding
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import Encoding from 'node-buffer-encoding';
|
||||
|
||||
// Encode an Uint8Array with the given encoding
|
||||
Encoding.encode ( new Uint8Array ([ 0, 255 ]), 'hex' ); // => '00ff'
|
||||
|
||||
// Encode a string with the given encoding
|
||||
Encoding.encodeStr ( 'hello', 'base64' ); // => 'aGVsbG8='
|
||||
|
||||
// Decode a string with the given encoding to an Uint8Array
|
||||
Encoding.decode ( '00ff', 'hex' ); // => Uint8Array(2) [ 0, 255 ]
|
||||
|
||||
// Decode a string with the given encoding to a string
|
||||
Encoding.decodeStr ( 'aGVsbG8=', 'base64' ); // => 'hello'
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT © Fabio Spampinato
|
||||
44
node_modules/node-buffer-encoding/src/index.ts
generated
vendored
Executable file
44
node_modules/node-buffer-encoding/src/index.ts
generated
vendored
Executable file
@@ -0,0 +1,44 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {Buffer} from 'node:buffer';
|
||||
import type {Encoding} from './types';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
const BufferEncoding = {
|
||||
|
||||
/* API */
|
||||
|
||||
encode: ( data: Uint8Array, encoding: Encoding ): string => {
|
||||
|
||||
return Buffer.from ( data ).toString ( encoding );
|
||||
|
||||
},
|
||||
|
||||
encodeStr: ( data: string, encoding: Encoding ): string => {
|
||||
|
||||
return Buffer.from ( data ).toString ( encoding );
|
||||
|
||||
},
|
||||
|
||||
decode: ( data: string, encoding: Encoding ): Uint8Array => {
|
||||
|
||||
const buffer = Buffer.from ( data, encoding );
|
||||
|
||||
return new Uint8Array ( buffer.buffer, buffer.byteOffset, buffer.byteLength );
|
||||
|
||||
},
|
||||
|
||||
decodeStr: ( data: string, encoding: Encoding ): string => {
|
||||
|
||||
return Buffer.from ( data, encoding ).toString ();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export default BufferEncoding;
|
||||
export type {Encoding};
|
||||
8
node_modules/node-buffer-encoding/src/types.ts
generated
vendored
Normal file
8
node_modules/node-buffer-encoding/src/types.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
/* MAIN */
|
||||
|
||||
type Encoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex';
|
||||
|
||||
/* EXPORT */
|
||||
|
||||
export type {Encoding};
|
||||
43
node_modules/node-buffer-encoding/test/index.js
generated
vendored
Normal file
43
node_modules/node-buffer-encoding/test/index.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
/* IMPORT */
|
||||
|
||||
import {describe} from 'fava';
|
||||
import BufferEncoding from '../dist/index.js';
|
||||
|
||||
/* MAIN */
|
||||
|
||||
describe ( 'BufferEncoding', it => {
|
||||
|
||||
it ( 'encodes an Uint8Array with the given encoding', t => {
|
||||
|
||||
const result = BufferEncoding.encode ( new Uint8Array ([ 0, 255 ]), 'hex' );
|
||||
|
||||
t.is ( result, '00ff' );
|
||||
|
||||
});
|
||||
|
||||
it ( 'encodes a string with the given encoding', t => {
|
||||
|
||||
const result = BufferEncoding.encodeStr ( 'hello', 'base64' );
|
||||
|
||||
t.is ( result, 'aGVsbG8=' );
|
||||
|
||||
});
|
||||
|
||||
it ( 'decodes a string with the given encoding to an Uint8Array', t => {
|
||||
|
||||
const result = BufferEncoding.decode ( '00ff', 'hex' );;
|
||||
|
||||
t.deepEqual ( result, new Uint8Array ([ 0, 255 ]) );
|
||||
|
||||
});
|
||||
|
||||
it ( 'decodes a string with the given encoding to a string', t => {
|
||||
|
||||
const result = BufferEncoding.decodeStr ( 'aGVsbG8=', 'base64' );
|
||||
|
||||
t.is ( result, 'hello' );
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
3
node_modules/node-buffer-encoding/tsconfig.json
generated
vendored
Executable file
3
node_modules/node-buffer-encoding/tsconfig.json
generated
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "tsex/tsconfig.json"
|
||||
}
|
||||
Reference in New Issue
Block a user