intial
This commit is contained in:
22
node_modules/@keyv/serialize/LICENSE
generated
vendored
Normal file
22
node_modules/@keyv/serialize/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017-2021 Luke Childs
|
||||
Copyright (c) 2021-2022 Jared Wray
|
||||
|
||||
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.
|
||||
15
node_modules/@keyv/serialize/README.md
generated
vendored
Normal file
15
node_modules/@keyv/serialize/README.md
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# @keyv/serialize [<img width="100" align="right" src="https://jaredwray.com/images/keyv-symbol.svg" alt="keyv">](https://github.com/jaredwra/keyv)
|
||||
|
||||
> Serialization functionality for [Keyv](https://github.com/jaredwray/keyv)
|
||||
|
||||
|
||||
[](https://github.com/jaredwray/keyv/actions/workflows/tests.yaml)
|
||||
[](https://codecov.io/gh/jaredwray/keyv)
|
||||
[](https://github.com/jaredwray/keyv/blob/main/LICENSE)
|
||||
[](https://npmjs.com/package/@keyv/serialize)
|
||||
|
||||
This is the serialization functionality for [Keyv](https://github.com/jaredwray/keyv/tree/main/packages/keyv). It is used to serialize and deserialize data for storage and retrieval. You can also create your own [custom serialization functions](https://github.com/jaredwray/keyv/tree/main/packages/keyv#custom-serializers).
|
||||
|
||||
## License
|
||||
|
||||
[MIT © Jared Wray](LISCENCE)
|
||||
84
node_modules/@keyv/serialize/dist/index.cjs
generated
vendored
Normal file
84
node_modules/@keyv/serialize/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/index.ts
|
||||
var index_exports = {};
|
||||
__export(index_exports, {
|
||||
defaultDeserialize: () => defaultDeserialize,
|
||||
defaultSerialize: () => defaultSerialize
|
||||
});
|
||||
module.exports = __toCommonJS(index_exports);
|
||||
var import_node_buffer = require("buffer");
|
||||
var _serialize = (data, escapeColonStrings = true) => {
|
||||
if (data === void 0 || data === null) {
|
||||
return "null";
|
||||
}
|
||||
if (typeof data === "string") {
|
||||
return JSON.stringify(
|
||||
escapeColonStrings && data.startsWith(":") ? `:${data}` : data
|
||||
);
|
||||
}
|
||||
if (import_node_buffer.Buffer.isBuffer(data)) {
|
||||
return JSON.stringify(`:base64:${data.toString("base64")}`);
|
||||
}
|
||||
if (data?.toJSON) {
|
||||
data = data.toJSON();
|
||||
}
|
||||
if (typeof data === "object") {
|
||||
let s = "";
|
||||
const array = Array.isArray(data);
|
||||
s = array ? "[" : "{";
|
||||
let first = true;
|
||||
for (const k in data) {
|
||||
const ignore = typeof data[k] === "function" || !array && data[k] === void 0;
|
||||
if (!Object.hasOwn(data, k) || ignore) {
|
||||
continue;
|
||||
}
|
||||
if (!first) {
|
||||
s += ",";
|
||||
}
|
||||
first = false;
|
||||
if (array) {
|
||||
s += _serialize(data[k], escapeColonStrings);
|
||||
} else if (data[k] !== void 0) {
|
||||
s += `${_serialize(k, false)}:${_serialize(data[k], escapeColonStrings)}`;
|
||||
}
|
||||
}
|
||||
s += array ? "]" : "}";
|
||||
return s;
|
||||
}
|
||||
return JSON.stringify(data);
|
||||
};
|
||||
var defaultSerialize = (data) => {
|
||||
return _serialize(data, true);
|
||||
};
|
||||
var defaultDeserialize = (data) => JSON.parse(data, (_, value) => {
|
||||
if (typeof value === "string") {
|
||||
if (value.startsWith(":base64:")) {
|
||||
return import_node_buffer.Buffer.from(value.slice(8), "base64");
|
||||
}
|
||||
return value.startsWith(":") ? value.slice(1) : value;
|
||||
}
|
||||
return value;
|
||||
});
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
defaultDeserialize,
|
||||
defaultSerialize
|
||||
});
|
||||
4
node_modules/@keyv/serialize/dist/index.d.cts
generated
vendored
Normal file
4
node_modules/@keyv/serialize/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
declare const defaultSerialize: (data: any) => string;
|
||||
declare const defaultDeserialize: <Value>(data: any) => Value;
|
||||
|
||||
export { defaultDeserialize, defaultSerialize };
|
||||
4
node_modules/@keyv/serialize/dist/index.d.ts
generated
vendored
Normal file
4
node_modules/@keyv/serialize/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
declare const defaultSerialize: (data: any) => string;
|
||||
declare const defaultDeserialize: <Value>(data: any) => Value;
|
||||
|
||||
export { defaultDeserialize, defaultSerialize };
|
||||
58
node_modules/@keyv/serialize/dist/index.js
generated
vendored
Normal file
58
node_modules/@keyv/serialize/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
// src/index.ts
|
||||
import { Buffer } from "buffer";
|
||||
var _serialize = (data, escapeColonStrings = true) => {
|
||||
if (data === void 0 || data === null) {
|
||||
return "null";
|
||||
}
|
||||
if (typeof data === "string") {
|
||||
return JSON.stringify(
|
||||
escapeColonStrings && data.startsWith(":") ? `:${data}` : data
|
||||
);
|
||||
}
|
||||
if (Buffer.isBuffer(data)) {
|
||||
return JSON.stringify(`:base64:${data.toString("base64")}`);
|
||||
}
|
||||
if (data?.toJSON) {
|
||||
data = data.toJSON();
|
||||
}
|
||||
if (typeof data === "object") {
|
||||
let s = "";
|
||||
const array = Array.isArray(data);
|
||||
s = array ? "[" : "{";
|
||||
let first = true;
|
||||
for (const k in data) {
|
||||
const ignore = typeof data[k] === "function" || !array && data[k] === void 0;
|
||||
if (!Object.hasOwn(data, k) || ignore) {
|
||||
continue;
|
||||
}
|
||||
if (!first) {
|
||||
s += ",";
|
||||
}
|
||||
first = false;
|
||||
if (array) {
|
||||
s += _serialize(data[k], escapeColonStrings);
|
||||
} else if (data[k] !== void 0) {
|
||||
s += `${_serialize(k, false)}:${_serialize(data[k], escapeColonStrings)}`;
|
||||
}
|
||||
}
|
||||
s += array ? "]" : "}";
|
||||
return s;
|
||||
}
|
||||
return JSON.stringify(data);
|
||||
};
|
||||
var defaultSerialize = (data) => {
|
||||
return _serialize(data, true);
|
||||
};
|
||||
var defaultDeserialize = (data) => JSON.parse(data, (_, value) => {
|
||||
if (typeof value === "string") {
|
||||
if (value.startsWith(":base64:")) {
|
||||
return Buffer.from(value.slice(8), "base64");
|
||||
}
|
||||
return value.startsWith(":") ? value.slice(1) : value;
|
||||
}
|
||||
return value;
|
||||
});
|
||||
export {
|
||||
defaultDeserialize,
|
||||
defaultSerialize
|
||||
};
|
||||
55
node_modules/@keyv/serialize/package.json
generated
vendored
Normal file
55
node_modules/@keyv/serialize/package.json
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"name": "@keyv/serialize",
|
||||
"version": "1.1.1",
|
||||
"description": "Serialization for Keyv",
|
||||
"type": "module",
|
||||
"main": "dist/index.cjs",
|
||||
"module": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./dist/index.cjs",
|
||||
"import": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jaredwray/keyv.git"
|
||||
},
|
||||
"keywords": [
|
||||
"keyv",
|
||||
"serialize",
|
||||
"key",
|
||||
"value",
|
||||
"store"
|
||||
],
|
||||
"author": "Jared Wray <me@jaredwray.com> (https://jaredwray.com)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jaredwray/keyv/issues"
|
||||
},
|
||||
"homepage": "https://github.com/jaredwray/keyv",
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^2.2.3",
|
||||
"@vitest/coverage-v8": "^3.2.4",
|
||||
"rimraf": "^6.0.1",
|
||||
"tsd": "^0.33.0",
|
||||
"typescript": "^5.9.2",
|
||||
"vitest": "^3.2.4",
|
||||
"@keyv/test-suite": "^2.1.1",
|
||||
"keyv": "^5.5.0"
|
||||
},
|
||||
"tsd": {
|
||||
"directory": "test"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"LICENSE"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "rimraf ./dist && tsup src/index.ts --format cjs,esm --dts --clean",
|
||||
"test": "biome check --write && vitest run --coverage",
|
||||
"test:ci": "biome check && vitest --run --sequence.setupFiles=list --coverage",
|
||||
"clean": "rimraf ./node_modules ./coverage ./dist"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user