Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dreambase-library

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dreambase-library - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

dist/typeson-simplified/types/number.d.ts

8

dist/typeson-simplified/presets/builtin.js

@@ -0,3 +1,3 @@

import numberDef from "../types/number.js";
import bigintDef from "../types/bigint.js";
import SpecialNumberDef from "../types/SpecialNumber.js";
import DateDef from "../types/Date.js";

@@ -8,6 +8,6 @@ import SetDef from "../types/Set.js";

import ArrayBufferDef from "../types/ArrayBuffer.js";
import Blob from "../types/Blob.js";
import BlobDef from "../types/Blob.js";
const builtin = {
...numberDef,
...bigintDef,
...SpecialNumberDef,
...DateDef,

@@ -18,4 +18,4 @@ ...SetDef,

...ArrayBufferDef,
...Blob,
...BlobDef,
};
export default builtin;

@@ -1,3 +0,3 @@

export declare function string2ArrayBuffer(str: string): ArrayBufferLike;
export declare function string2ArrayBuffer(str: string): ArrayBuffer;
export declare function arrayBuffer2String(buf: ArrayBuffer): string;
//# sourceMappingURL=string2arraybuffer.d.ts.map
import { TypeDefSet } from "./TypeDefSet.js";
export interface TypeDef<T = unknown, TReplaced = unknown> {
test?: (val: T, toStringTag: string) => boolean | "cache";
test?: (val: T, toStringTag: string) => boolean;
replace: (val: T, altChannel: any, typeDefs: TypeDefSet) => TReplaced | (TReplaced & {

@@ -5,0 +5,0 @@ $t: string;

@@ -5,2 +5,3 @@ import { TypeDef } from "./TypeDef.js";

boolean?: TypeDef<boolean>;
number?: TypeDef<number>;
undefined?: TypeDef<undefined>;

@@ -10,4 +11,2 @@ bigint?: TypeDef<bigint>;

function?: TypeDef<Function>;
NormalNumber?: TypeDef<number>;
SpecialNumber?: TypeDef<number>;
ArrayBuffer?: TypeDef<ArrayBuffer>;

@@ -14,0 +13,0 @@ Date?: TypeDef<Date>;

@@ -5,6 +5,6 @@ declare const _default: {

$t: string;
b: string;
v: string;
};
revive: ({ b }: {
b: any;
revive: ({ v }: {
v: any;
}) => ArrayBuffer;

@@ -11,0 +11,0 @@ };

@@ -1,2 +0,2 @@

import { b64LexDecode, b64LexEncode } from "../../common/b64lex.js";
import { arrayBuffer2String, string2ArrayBuffer, } from "../string2arraybuffer.js";
export default {

@@ -6,11 +6,8 @@ ArrayBuffer: {

$t: "ArrayBuffer",
b: b64LexEncode(ab),
v: arrayBuffer2String(ab),
}),
revive: ({ b }) => {
const ba = b64LexDecode(b);
return ba.buffer.byteLength === ba.byteLength
? ba.buffer
: ba.buffer.slice(ba.byteOffset, ba.byteOffset + ba.byteLength);
revive: ({ v }) => {
return string2ArrayBuffer(v);
},
},
};
import { TypeDefSet } from "../TypeDefSet.js";
export declare const MAXUINT64: number | bigint;
declare const bigIntDef: TypeDefSet;
export default bigIntDef;
//# sourceMappingURL=bigint.d.ts.map

@@ -1,24 +0,9 @@

import { b64ToBigInt, bigint2B64 } from "../../common/bigint-conversion.js";
export const MAXUINT64 = typeof BigInt !== "undefined"
? BigInt("18446744073709551615")
: 281474976710655;
const bigIntDef = {
bigint: {
replace: (realVal) => {
if (realVal <= MAXUINT64) {
// Negative and realtively small numbers - represent as normal numbers
return { $t: "bigint", v: "" + realVal };
}
else {
// Very large positive numbers - compress to base64
const b64 = bigint2B64(realVal);
return {
$t: "bigint",
b64,
};
}
return { $t: "bigint", v: "" + realVal };
},
revive: (obj) => ("v" in obj ? BigInt(obj.v) : b64ToBigInt(obj.b64)),
revive: (obj) => BigInt(obj.v),
},
};
export default bigIntDef;
import { FakeBlob } from "../FakeBlob.js";
declare const _default: {
Blob: {
test: (blob: FakeBlob, toStringTag: string) => boolean;
replace: (blob: FakeBlob | Blob) => {
test: (blob: Blob | FakeBlob, toStringTag: string) => boolean;
replace: (blob: Blob | FakeBlob) => {
$t: string;
mimeType: string | undefined;
data: string;
v: string;
type: string | undefined;
};
revive: ({ mimeType, data }: {
mimeType: any;
data: any;
}) => FakeBlob | Blob;
revive: ({ type, v }: {
type: any;
v: any;
}) => Blob | FakeBlob;
};

@@ -15,0 +15,0 @@ };

@@ -1,5 +0,4 @@

import { b64decode, b64encode } from "../../common/base64.js";
import { FakeBlob } from "../FakeBlob.js";
import { readBlobSync } from "../readBlobSync.js";
import { string2ArrayBuffer } from "../string2arraybuffer.js";
import { arrayBuffer2String, string2ArrayBuffer, } from "../string2arraybuffer.js";
export default {

@@ -10,14 +9,14 @@ Blob: {

$t: "Blob",
mimeType: blob.type,
data: b64encode(blob instanceof FakeBlob
? blob.buf
: string2ArrayBuffer(readBlobSync(blob))),
v: blob instanceof FakeBlob
? arrayBuffer2String(blob.buf)
: readBlobSync(blob),
type: blob.type,
}),
revive: ({ mimeType, data }) => {
const ab = b64decode(data);
revive: ({ type, v }) => {
const ab = string2ArrayBuffer(v);
return typeof Blob !== undefined
? new Blob([ab])
: new FakeBlob(ab, mimeType);
: new FakeBlob(ab, type);
},
},
};

@@ -5,6 +5,6 @@ declare const _default: {

$t: string;
date: string;
v: string;
};
revive: ({ date }: {
date: any;
revive: ({ v }: {
v: any;
}) => Date;

@@ -11,0 +11,0 @@ };

@@ -5,6 +5,6 @@ export default {

$t: "Date",
date: isNaN(date.getTime()) ? "NaN" : date.toISOString(),
v: isNaN(date.getTime()) ? "NaN" : date.toISOString(),
}),
revive: ({ date }) => new Date(date === "NaN" ? NaN : Date.parse(date)),
revive: ({ v }) => new Date(v === "NaN" ? NaN : Date.parse(v)),
},
};

@@ -23,14 +23,18 @@ import { _global } from "../../common/_global.js";

// to contain the b64 property directly.
replace: (a, _, typeDefs) => ({
$t: typeName,
b: typeDefs.ArrayBuffer.replace(a.byteOffset === 0 && a.byteLength === a.buffer.byteLength
? a.buffer
: a.buffer.slice(a.byteOffset, a.byteOffset + a.byteLength), _, typeDefs).b,
}),
revive: ({ b }, _, typeDefs) => {
replace: (a, _, typeDefs) => {
const result = {
$t: typeName,
v: typeDefs.ArrayBuffer.replace(a.byteOffset === 0 && a.byteLength === a.buffer.byteLength
? a.buffer
: a.buffer.slice(a.byteOffset, a.byteOffset + a.byteLength), _, typeDefs).v,
};
debugger;
return result;
},
revive: ({ v }, _, typeDefs) => {
const TypedArray = _global[typeName];
return (TypedArray &&
new TypedArray(typeDefs.ArrayBuffer.revive({ b }, _, typeDefs)));
new TypedArray(typeDefs.ArrayBuffer.revive({ v }, _, typeDefs)));
},
},
}), {});
import { TypeDefSet } from "./TypeDefSet.js";
export declare function escapeDollarProps(value: any): any;
export declare function TypesonSimplified(...typeDefsInputs: TypeDefSet[]): {

@@ -3,0 +4,0 @@ stringify(value: any, alternateChannel?: any, space?: number | undefined): string;

@@ -5,3 +5,3 @@ const { toString: toStr } = {};

}
function escapeDollarProps(value) {
export function escapeDollarProps(value) {
const keys = Object.keys(value);

@@ -82,6 +82,2 @@ let dollarKeys = null;

switch (typeof realVal) {
case "number":
return isNaN(realVal) || realVal === Infinity || realVal === -Infinity
? typeDefs.SpecialNumber
: typeDefs.NormalNumber;
case "object":

@@ -99,4 +95,3 @@ case "function": {

const toStringTag = getToStringTag(realVal);
const entry = Object.entries(typeDefs).find(([typeName, typeDef]) => (typeDef === null || typeDef === void 0 ? void 0 : typeDef.test) ? typeDef.test(realVal, toStringTag)
: typeName === toStringTag);
const entry = Object.entries(typeDefs).find(([typeName, typeDef]) => { var _a, _b; return (_b = (_a = typeDef === null || typeDef === void 0 ? void 0 : typeDef.test) === null || _a === void 0 ? void 0 : _a.call(typeDef, realVal, toStringTag)) !== null && _b !== void 0 ? _b : typeName === toStringTag; });
typeDef = entry === null || entry === void 0 ? void 0 : entry[1];

@@ -103,0 +98,0 @@ if (!typeDef) {

{
"name": "dreambase-library",
"version": "1.0.10",
"version": "1.0.11",
"description": "Library of dreambase-related code for use in other libraries.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc