You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

functionalscript

Package Overview
Dependencies
Maintainers
1
Versions
467
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

functionalscript - npm Package Compare versions

Comparing version

to
0.6.11

crypto/sign/module.f.d.ts

2

bnf/data/module.f.d.ts

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

import type { Rule as FRule } from '../module.f.ts';
import { type Rule as FRule } from '../module.f.ts';
export type TerminalRange = number;

@@ -3,0 +3,0 @@ export type Sequence = readonly string[];

import { stringToCodePointList } from "../../text/utf16/module.f.js";
import { toArray } from "../../types/list/module.f.js";
import { map, toArray } from "../../types/list/module.f.js";
import { oneEncode, } from "../module.f.js";
const { entries } = Object;

@@ -43,6 +44,7 @@ const find = (map) => (fr) => {

};
const mapOneEncode = map(oneEncode);
const data = (dr) => {
switch (typeof dr) {
case 'string': {
return sequence(toArray(stringToCodePointList(dr)));
return sequence(toArray(mapOneEncode(stringToCodePointList(dr))));
}

@@ -49,0 +51,0 @@ case 'number':

declare const _default: {
toData: () => void;
toData: (() => void)[];
variantTest: () => void;
example: () => void;
};
export default _default;

@@ -0,7 +1,64 @@

import { stringify } from "../../json/module.f.js";
import { sort } from "../../types/object/module.f.js";
import { range } from "../module.f.js";
import { classic, deterministic } from "../testlib.f.js";
import { toData } from "./module.f.js";
export default {
toData: () => {
const c = toData(classic());
const d = toData(deterministic());
toData: [
() => {
const c = toData(classic());
const d = toData(deterministic());
},
() => {
const stringRule = 'true';
const result = stringify(sort)(toData(stringRule));
if (result != '[{"":["0","1","2","3"],"0":1946157172,"1":1912602738,"2":1962934389,"3":1694498917},""]') {
throw result;
}
},
() => {
const terminalRangeRule = range('AF');
const result = stringify(sort)(toData(terminalRangeRule));
if (result != '[{"":1090519110},""]') {
throw result;
} //1090519110 = 65 * 2^24 + 70
},
() => {
const sequenceRangeRule = [range('AF'), range('af')];
const result = stringify(sort)(toData(sequenceRangeRule));
if (result != '[{"":["0","1"],"0":1090519110,"1":1627390054},""]') {
throw result;
}
},
() => {
const lazyRule = () => 'true';
const result = stringify(sort)(toData(lazyRule));
if (result != '[{"":1946157172,"0":1912602738,"1":1962934389,"2":1694498917,"lazyRule":["","0","1","2"]},"lazyRule"]') {
throw result;
}
},
() => {
const varintRule = { true: 'true', false: 'false' };
const result = stringify(sort)(toData(varintRule));
const expected = '[{"":{"false":"5","true":"0"},"0":["1","2","3","4"],"1":1946157172,"2":1912602738,"3":1962934389,"4":1694498917,"5":["6","7","8","9","4"],"6":1711276134,"7":1627390049,"8":1811939436,"9":1929379955},""]';
if (result != expected) {
throw [result, expected];
}
},
() => {
const lazyRule = () => 'true';
const lazyRule0 = () => 'false';
const result = stringify(sort)(toData([lazyRule, lazyRule0]));
const expected = '[{"":["lazyRule","lazyRule0"],"0":1946157172,"1":1912602738,"2":1962934389,"3":1694498917,"4":1711276134,"5":1627390049,"6":1811939436,"7":1929379955,"lazyRule":["0","1","2","3"],"lazyRule0":["4","5","6","7","3"]},""]';
if (result != expected) {
throw [result, expected];
}
},
],
variantTest: () => {
const varintRule = { a: 'a', b: 'b' };
const result = stringify(sort)(toData(varintRule));
if (result != '[{"":{"a":"0","b":"2"},"0":["1"],"1":1627390049,"2":["3"],"3":1644167266},""]') {
throw result;
}
},

@@ -8,0 +65,0 @@ example: () => {

@@ -51,11 +51,16 @@ /**

const vbl = vec(blockLength);
// a and b should have the same size
const xor = (a) => (b) => vbl(a ^ b);
return k => m => {
return k => {
const k1 = length(k) > blockLength ? c([k]) : k;
const k2 = concat(k1)(vec(blockLength - length(k1))(0n));
const xk2 = xor(k2);
const f = (p, msg) => c([xk2(p), msg]);
const m1 = f(ip, m);
return f(op, m1);
const f = (p) => {
const x = xk2(p);
return (msg) => c([x, msg]);
};
const fip = f(ip);
const fop = f(op);
return m => fop(fip(m));
};
};

@@ -40,3 +40,3 @@ import type { Array16, Array8 } from '../../types/array/module.f.ts';

* state = sha224.append(state)(s)
* const h = sha224.end(state) // 0x619cba8e8e05826e9b8c519c0a5c68f4fb653e8a3d8aa04bb2c8cd4cn
* const h = sha224.end(state) // 0x1_619cba8e8e05826e9b8c519c0a5c68f4fb653e8a3d8aa04bb2c8cd4cn
* ```

@@ -43,0 +43,0 @@ */

@@ -0,5 +1,6 @@

import { type CsiConsole } from '../../text/sgr/module.f.ts';
import type * as Result from '../../types/result/module.f.ts';
import type { Io, Performance } from '../../io/module.f.ts';
import { type ModuleMap } from '../module.f.ts';
type Log<T> = (v: string) => (state: T) => T;
type Log<T> = CsiConsole;
type Measure<T> = <R>(f: () => R) => (state: T) => readonly [R, number, T];

@@ -15,2 +16,3 @@ type Input<T> = {

};
export declare const isTest: (s: string) => boolean;
export declare const test: <T>(input: Input<T>) => readonly [number, T];

@@ -17,0 +19,0 @@ export declare const anyLog: (f: (s: string) => void) => (s: string) => <T>(state: T) => T;

import { entries, fold } from "../../types/list/module.f.js";
import { reset, fgGreen, fgRed, bold } from "../../text/sgr/module.f.js";
import { reset, fgGreen, fgRed, bold, stdio, stderr } from "../../text/sgr/module.f.js";
import { env, loadModuleMap } from "../module.f.js";
const isTest = (s) => s.endsWith('test.f.js') || s.endsWith('test.f.ts');
export const isTest = (s) => s.endsWith('test.f.js') || s.endsWith('test.f.ts');
const addPass = (delta) => (ts) => ({ ...ts, time: ts.time + delta, pass: ts.pass + 1 });

@@ -33,7 +33,7 @@ const addFail = (delta) => (ts) => ({ ...ts, time: ts.time + delta, fail: ts.fail + 1 });

// https://github.com/OndraM/ci-detector/blob/main/src/Ci/GitHubActions.php
state = error(`::error file=${k},line=1,title=[3]['a']()::${r}`)(state);
error(`::error file=${k},line=1,title=[3]['a']()::${r}`);
}
else {
state = error(`${i}() ${fgRed}error${reset}, ${timeFormat(delta)}`)(state);
state = error(`${fgRed}${r}${reset}`)(state);
error(`${i}() ${fgRed}error${reset}, ${timeFormat(delta)}`);
error(`${fgRed}${r}${reset}`);
}

@@ -43,3 +43,3 @@ }

ts = addPass(delta)(ts);
state = log(`${i}() ${fgGreen}ok${reset}, ${timeFormat(delta)}`)(state);
log(`${i}() ${fgGreen}ok${reset}, ${timeFormat(delta)}`);
}

@@ -53,3 +53,3 @@ [ts, state] = next(r)([ts, state]);

const f = ([k, v]) => ([time, state]) => {
state = log(`${i}${k}:`)(state);
log(`${i}${k}:`);
[time, state] = next(v)([time, state]);

@@ -67,3 +67,3 @@ return [time, state];

if (isTest(k)) {
state = log(`testing ${k}`)(state);
log(`testing ${k}`);
[ts, state] = test('| ')(v.default)([ts, state]);

@@ -77,4 +77,4 @@ }

const fgFail = ts.fail === 0 ? fgGreen : fgRed;
state = log(`${bold}Number of tests: pass: ${fgGreen}${ts.pass}${reset}${bold}, fail: ${fgFail}${ts.fail}${reset}${bold}, total: ${ts.pass + ts.fail}${reset}`)(state);
state = log(`${bold}Time: ${timeFormat(ts.time)}${reset}`)(state);
log(`${bold}Number of tests: pass: ${fgGreen}${ts.pass}${reset}${bold}, fail: ${fgFail}${ts.fail}${reset}${bold}, total: ${ts.pass + ts.fail}${reset}`);
log(`${bold}Time: ${timeFormat(ts.time)}${reset}`);
return [ts.fail !== 0 ? 1 : 0, state];

@@ -94,4 +94,4 @@ };

moduleMap: await loadModuleMap(io),
log: anyLog(io.console.log),
error: anyLog(io.console.error),
log: stdio(io), // anyLog(io.console.log),
error: stderr(io), // anyLog(io.console.error),
measure: measure(io.performance),

@@ -98,0 +98,0 @@ tryCatch: io.tryCatch,

@@ -28,2 +28,3 @@ import type { Result } from '../types/result/module.f.ts';

export type Fs = {
readonly writeSync: (fd: number, s: string) => void;
readonly writeFileSync: (file: string, data: string) => void;

@@ -64,2 +65,6 @@ readonly readFileSync: (path: string, options: BufferEncoding) => string | null;

};
export type Writable = {
readonly fd: number;
readonly isTTY: boolean;
};
/**

@@ -74,2 +79,4 @@ * Node.js Process interface

readonly cwd: () => string;
readonly stdout: Writable;
readonly stderr: Writable;
};

@@ -76,0 +83,0 @@ /**

@@ -8,2 +8,3 @@ import { at } from "../../types/ordered_map/module.f.js";

fs: {
writeSync: (fd, s) => { },
writeFileSync: (_file, _data) => { },

@@ -26,2 +27,4 @@ readFileSync: (path, _options) => { return at(path)(files); },

cwd: () => '',
stdout: { fd: 1, isTTY: false },
stderr: { fd: 2, isTTY: false },
},

@@ -28,0 +31,0 @@ asyncImport: () => Promise.reject(),

{
"name": "functionalscript",
"version": "0.6.10",
"version": "0.6.11",
"type": "module",

@@ -47,5 +47,6 @@ "files": [

"devDependencies": {
"@types/node": "^22.15.30",
"@types/node": "^24.0.15",
"@typescript/native-preview": "^7.0.0-dev.20250719.1",
"typescript": "^5.8.3"
}
}

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

import type { Io, Writable } from "../../io/module.f.ts";
export declare const backspace: string;

@@ -26,2 +27,6 @@ type End = 'm';

export declare const createConsoleText: (stdout: Stdout) => WriteText;
export type CsiConsole = (s: string) => void;
export declare const console: ({ fs: { writeSync } }: Io) => (w: Writable) => CsiConsole;
export declare const stdio: (io: Io) => CsiConsole;
export declare const stderr: (io: Io) => CsiConsole;
export {};
// Co control codes
// https://en.wikipedia.org/wiki/ANSI_escape_code#C0_control_codes
export const backspace = '\x08';
const begin = '\x1b[';
/**

@@ -11,3 +12,3 @@ * Control Sequence Introducer (CSI) escape sequence.

*/
export const csi = (end) => code => `\x1b[${code.toString()}${end}`;
export const csi = (end) => code => `${begin}${code.toString()}${end}`;
/**

@@ -35,1 +36,9 @@ * Specialization of CSI for Select Graphic Rendition (SGR) sequences.

};
export const console = ({ fs: { writeSync } }) => (w) => {
const { isTTY } = w;
return isTTY
? (s) => writeSync(w.fd, s + '\n')
: (s) => writeSync(w.fd, s.replace(/\x1b\[[0-9;]*m/g, '') + '\n');
};
export const stdio = (io) => console(io)(io.process.stdout);
export const stderr = (io) => console(io)(io.process.stderr);

@@ -155,1 +155,2 @@ import { type List, type Thunk } from '../list/module.f.ts';

export declare const u8List: ({ popFront }: BitOrder) => (v: Vec) => Thunk<number>;
export declare const listToVec: (bo: BitOrder) => (list: List<Vec>) => Vec;

@@ -139,1 +139,2 @@ /**

};
export const listToVec = (bo) => fold(bo.concat)(empty);