🇻8️ JavaScript V8 engine specific utilities.
import { base64Decode } from "@corefunc/v8/base64/decode";
// "example text"
console.log(base64Decode("ZXhhbXBsZSB0ZXh0"));
import { argvParse } from "@corefunc/v8/cli/argv-parse";
console.dir(argvParse());
// "calc-md5=movie.mp4"
// { 'calc-md5': 'movie.mp4' }
import { envParse } from "@corefunc/v8/cli/env-parse";
console.dir(envParse());
// { SHELL: "/bin/zsh", SPACESHIP_VERSION: 3.16 }
import { clone } from "@corefunc/v8/clone/clone";
const obj = { prop: "original" };
const array = [obj];
const clonedArray = clone(array);
array[0].prop = "changed";
// [ { prop: 'changed' } ]
console.log(array);
// [ { prop: 'original' } ]
console.log(clonedArray);
import { clone } from "@corefunc/v8/clone/clone";
class Omega {
x = 1;
y = 2;
}
const omegaOne = new Omega();
const omegaTwo = clone(omegaOne, true);
omegaOne.x = -10;
// Omega { x: -10, y: 2 }
console.log(omegaOne);
// Omega { x: 1, y: 2 }
console.log(omegaTwo);
import { clone } from "@corefunc/v8/clone/clone";
const obj = { prop: "original" };
const setOriginal = new Set([obj]);
const setCloned = clone(setOriginal);
obj.prop = "changed";
// Set(1) { { prop: 'changed' } }
console.log(setOriginal);
// Set(1) { { prop: 'original' } }
console.log(setCloned);
import { clone } from "@corefunc/v8/clone/clone";
const obj = { prop: "here is my password" };
const mapFirst = new Map([["secret", obj]]);
const mapSecond = clone(mapFirst);
const secret = mapFirst.get("secret");
secret.prop = "there is no secret anymore";
// Map(1) { 'secret' => { prop: 'there is no secret anymore' } }
console.log(mapFirst);
// Map(1) { 'secret' => { prop: 'here is my password' } }
console.log(mapSecond);
import { clone } from "@corefunc/v8/clone/clone";
const alpha = new Error(`Just error`);
const beta = clone(alpha);
alpha.message = `Now it's not`;
// `Now it's not`
console.log(alpha.message);
// `Just error`
console.log(beta.message);
import {
cloneMarshalling,
} from "@corefunc/v8/clone/clone-marshalling";
class Omega {
x = 1;
y = 2;
}
const omegaOne = new Omega();
const omegaTwo = cloneMarshalling(omegaOne);
omegaOne.x = -10;
// Omega { x: -10, y: 2 }
console.log(omegaOne);
// Omega { x: 1, y: 2 }
console.log(omegaTwo);
import {
cloneShallow,
} from "@corefunc/v8/clone/clone-shallow";
class Omega {
x = 1;
y = 2;
}
const omegaOne = new Omega();
const omegaTwo = cloneShallow(omegaOne);
omegaOne.x = -10;
// Omega { x: -10, y: 2 }
console.log(omegaOne);
// { x: 1, y: 2 }
console.log(omegaTwo);
import {
deserializeFromString,
} from "@corefunc/v8/deserialize/from-string";
class Omega {
x = 1;
y = 2;
}
const binaryString = `ÿ\ro"\x01xI\x02"\x01yI\x04{\x02`;
const obj = deserializeFromString(binaryString);
const omega = deserializeFromString(binaryString, Omega);
// { x: 1, y: 2 }
console.log(obj);
// Omega { x: 1, y: 2 }
console.log(omega);
import {
generateNumber,
} from "@corefunc/v8/generate/number";
const integer = await generateNumber(-100, 100);
// 56
console.log(integer);
import {
generateTimeStamp,
} from '@corefunc/v8/generate/time-stamp';
const timeStamp = generateTimeStamp(0, 31);
// "2000123101020312345678901234567"
console.log(timeStamp);
import {
generateUuid4,
} from "@corefunc/v8/generate/uuid4";
// "71ce5138-c908-47b0-b599-327bcec8d213"
console.log(generateUuid4());
import {
generateUuid5,
} from "@corefunc/v8/generate/uuid5";
const name = `{"a":1}`;
const nameSpace = "924a63b2-7e67-435e-94b7-57b5f806b105";
// "a923cf68-cd80-577c-981d-c219fbcb3bee"
console.log(generateUuid5(name, nameSpace));
import {
serializeToString,
} from "@corefunc/v8/serialize/to-string";
class Omega {
x = 1;
y = 2;
}
const omega = new Omega();
const binaryString = serializeToString(omega);
// `ÿ\ro"\x01xI\x02"\x01yI\x04{\x02`
console.log(binaryString);
Generated using TypeDoc