New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gamla

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gamla - npm Package Compare versions

Comparing version 69.0.0 to 72.0.0

4

esm/src/debug.d.ts

@@ -12,4 +12,6 @@ import { AsyncFunction, Func, ReturnTypeUnwrapped } from "./typing.js";

export declare const catchWithNull: <F extends Func>(f: F) => AugmentReturnType<F, null>;
export declare const catchSpecificError: (error: Error) => <F extends AsyncFunction, G extends (...args: Parameters<F>) => any>(fallback: G, f: F) => (...args: Parameters<F>) => ReturnType<F> | ReturnType<G>;
export declare const catchErrorWithId: (id: string) => <F extends AsyncFunction, G extends (...args: Parameters<F>) => any>(fallback: G, f: F) => (...args: Parameters<F>) => ReturnType<F> | ReturnType<G>;
export declare const throwerCatcher: () => [() => never, <F extends AsyncFunction, G extends (...args: Parameters<F>) => any>(fallback: G, f: F) => (...args: Parameters<F>) => ReturnType<F> | ReturnType<G>];
export declare const catchErrorWithIdAndValue: <T>(id: string) => <F extends AsyncFunction, G extends (value: T) => any>(fallback: G, f: F) => (...args: Parameters<F>) => ReturnType<F> | ReturnType<G>;
export declare const throwerCatcherWithValue: <T>() => [(value: T) => never, <F extends AsyncFunction, G extends (value: T) => any>(fallback: G, f: F) => (...args: Parameters<F>) => ReturnType<F> | ReturnType<G>];
export {};

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

import { currentLocation } from "./trace.js";
import { randomUUID } from "crypto";
import { pipe } from "./composition.js";
import { pairRight } from "./juxt.js";
import { pipe } from "./composition.js";
import { isPromise } from "./promise.js";
import { currentLocation } from "./trace.js";
export const sideLog = (x) => {

@@ -91,3 +92,3 @@ console.log(currentLocation(3), x);

export const catchWithNull = (f) => tryCatch(f, () => null);
export const catchSpecificError = (error) =>
export const catchErrorWithId = (id) =>
// deno-lint-ignore no-explicit-any

@@ -101,3 +102,3 @@ (fallback, f) =>

catch (e) {
if (e === error)
if (e.id === id)
return fallback(...xs);

@@ -107,9 +108,40 @@ throw e;

};
const makeErrorWithId = (id) => {
const err = new Error();
// @ts-expect-error changes the typing of `Error`
err.id = id;
return err;
};
export const throwerCatcher = () => {
const specificError = new Error();
const catcher = catchSpecificError(specificError);
const id = randomUUID();
const catcher = catchErrorWithId(id);
const thrower = () => {
throw specificError;
throw makeErrorWithId(id);
};
return [thrower, catcher];
};
export const catchErrorWithIdAndValue = (id) =>
// deno-lint-ignore no-explicit-any
(fallback, f) =>
// @ts-expect-error cannot infer
async (...xs) => {
try {
return await f(...xs);
}
catch (e) {
if (e.id === id)
return fallback(e.payload);
throw e;
}
};
export const throwerCatcherWithValue = () => {
const id = randomUUID();
const catcher = catchErrorWithIdAndValue(id);
const thrower = (value) => {
const e = makeErrorWithId(id);
// @ts-expect-error changes the typing of `Error`
e.payload = value;
throw e;
};
return [thrower, catcher];
};

@@ -12,2 +12,3 @@ import { AsyncFunction, ElementOf } from "./typing.js";

export declare const retry: <F extends AsyncFunction>(waitMs: number, times: number, f: F) => F;
export declare const hash: <T>(x: T, maxLength: number) => string;
export {};

@@ -0,7 +1,8 @@

import crypto from "crypto";
import stableHash from "stable-hash";
import { pipe } from "./composition.js";
import { juxt, pairRight, stack } from "./juxt.js";
import { prop, spread } from "./operator.js";
import { pipe } from "./composition.js";
import { catchSpecificError } from "./debug.js";
import { map } from "./map.js";
import { applySpec } from "./mapping.js";
import { prop, spread } from "./operator.js";
import { sleep } from "./time.js";

@@ -51,2 +52,16 @@ const executeTasks = (execute) => pipe(

};
const catchSpecificError = (error) =>
// deno-lint-ignore no-explicit-any
(fallback, f) =>
// @ts-expect-error cannot infer
async (...xs) => {
try {
return await f(...xs);
}
catch (e) {
if (e === error)
return fallback(...xs);
throw e;
}
};
export const timerCatcher = () => {

@@ -96,1 +111,4 @@ const error = new Error("Timed out");

export const retry = (waitMs, times, f) => conditionalRetry(() => true)(waitMs, times, f);
export const hash = (x, maxLength) =>
// @ts-ignore-error not sure why, but this triggers an error in deno but no in node
crypto.createHash("MD5").update(stableHash(x)).digest("hex").substring(0, maxLength);
{
"name": "gamla",
"version": "69.0.0",
"version": "72.0.0",
"description": "Functional programming with async and type safety",

@@ -24,2 +24,5 @@ "repository": {

},
"dependencies": {
"stable-hash": "*"
},
"devDependencies": {

@@ -26,0 +29,0 @@ "@types/node": "^20.9.0",

@@ -12,4 +12,6 @@ import { AsyncFunction, Func, ReturnTypeUnwrapped } from "./typing.js";

export declare const catchWithNull: <F extends Func>(f: F) => AugmentReturnType<F, null>;
export declare const catchSpecificError: (error: Error) => <F extends AsyncFunction, G extends (...args: Parameters<F>) => any>(fallback: G, f: F) => (...args: Parameters<F>) => ReturnType<F> | ReturnType<G>;
export declare const catchErrorWithId: (id: string) => <F extends AsyncFunction, G extends (...args: Parameters<F>) => any>(fallback: G, f: F) => (...args: Parameters<F>) => ReturnType<F> | ReturnType<G>;
export declare const throwerCatcher: () => [() => never, <F extends AsyncFunction, G extends (...args: Parameters<F>) => any>(fallback: G, f: F) => (...args: Parameters<F>) => ReturnType<F> | ReturnType<G>];
export declare const catchErrorWithIdAndValue: <T>(id: string) => <F extends AsyncFunction, G extends (value: T) => any>(fallback: G, f: F) => (...args: Parameters<F>) => ReturnType<F> | ReturnType<G>;
export declare const throwerCatcherWithValue: <T>() => [(value: T) => never, <F extends AsyncFunction, G extends (value: T) => any>(fallback: G, f: F) => (...args: Parameters<F>) => ReturnType<F> | ReturnType<G>];
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.throwerCatcher = exports.catchSpecificError = exports.catchWithNull = exports.tryCatch = exports.coerce = exports.assert = exports.timeit = exports.logBefore = exports.logAfter = exports.logAround = exports.sideLog = void 0;
const trace_js_1 = require("./trace.js");
exports.throwerCatcherWithValue = exports.catchErrorWithIdAndValue = exports.throwerCatcher = exports.catchErrorWithId = exports.catchWithNull = exports.tryCatch = exports.coerce = exports.assert = exports.timeit = exports.logBefore = exports.logAfter = exports.logAround = exports.sideLog = void 0;
const crypto_1 = require("crypto");
const composition_js_1 = require("./composition.js");
const juxt_js_1 = require("./juxt.js");
const composition_js_1 = require("./composition.js");
const promise_js_1 = require("./promise.js");
const trace_js_1 = require("./trace.js");
const sideLog = (x) => {

@@ -103,3 +104,3 @@ console.log((0, trace_js_1.currentLocation)(3), x);

exports.catchWithNull = catchWithNull;
const catchSpecificError = (error) =>
const catchErrorWithId = (id) =>
// deno-lint-ignore no-explicit-any

@@ -113,3 +114,3 @@ (fallback, f) =>

catch (e) {
if (e === error)
if (e.id === id)
return fallback(...xs);

@@ -119,8 +120,14 @@ throw e;

};
exports.catchSpecificError = catchSpecificError;
exports.catchErrorWithId = catchErrorWithId;
const makeErrorWithId = (id) => {
const err = new Error();
// @ts-expect-error changes the typing of `Error`
err.id = id;
return err;
};
const throwerCatcher = () => {
const specificError = new Error();
const catcher = (0, exports.catchSpecificError)(specificError);
const id = (0, crypto_1.randomUUID)();
const catcher = (0, exports.catchErrorWithId)(id);
const thrower = () => {
throw specificError;
throw makeErrorWithId(id);
};

@@ -130,1 +137,28 @@ return [thrower, catcher];

exports.throwerCatcher = throwerCatcher;
const catchErrorWithIdAndValue = (id) =>
// deno-lint-ignore no-explicit-any
(fallback, f) =>
// @ts-expect-error cannot infer
async (...xs) => {
try {
return await f(...xs);
}
catch (e) {
if (e.id === id)
return fallback(e.payload);
throw e;
}
};
exports.catchErrorWithIdAndValue = catchErrorWithIdAndValue;
const throwerCatcherWithValue = () => {
const id = (0, crypto_1.randomUUID)();
const catcher = (0, exports.catchErrorWithIdAndValue)(id);
const thrower = (value) => {
const e = makeErrorWithId(id);
// @ts-expect-error changes the typing of `Error`
e.payload = value;
throw e;
};
return [thrower, catcher];
};
exports.throwerCatcherWithValue = throwerCatcherWithValue;

@@ -12,2 +12,3 @@ import { AsyncFunction, ElementOf } from "./typing.js";

export declare const retry: <F extends AsyncFunction>(waitMs: number, times: number, f: F) => F;
export declare const hash: <T>(x: T, maxLength: number) => string;
export {};
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.retry = exports.conditionalRetry = exports.timeout = exports.timerCatcher = exports.batch = void 0;
exports.hash = exports.retry = exports.conditionalRetry = exports.timeout = exports.timerCatcher = exports.batch = void 0;
const crypto_1 = __importDefault(require("crypto"));
const stable_hash_1 = __importDefault(require("stable-hash"));
const composition_js_1 = require("./composition.js");
const juxt_js_1 = require("./juxt.js");
const operator_js_1 = require("./operator.js");
const composition_js_1 = require("./composition.js");
const debug_js_1 = require("./debug.js");
const map_js_1 = require("./map.js");
const mapping_js_1 = require("./mapping.js");
const operator_js_1 = require("./operator.js");
const time_js_1 = require("./time.js");

@@ -55,5 +59,19 @@ const executeTasks = (execute) => (0, composition_js_1.pipe)(

exports.batch = batch;
const catchSpecificError = (error) =>
// deno-lint-ignore no-explicit-any
(fallback, f) =>
// @ts-expect-error cannot infer
async (...xs) => {
try {
return await f(...xs);
}
catch (e) {
if (e === error)
return fallback(...xs);
throw e;
}
};
const timerCatcher = () => {
const error = new Error("Timed out");
const catcher = (0, debug_js_1.catchSpecificError)(error);
const catcher = catchSpecificError(error);
const thrower = timeoutHelper(error);

@@ -103,1 +121,5 @@ return [thrower, catcher];

exports.retry = retry;
const hash = (x, maxLength) =>
// @ts-ignore-error not sure why, but this triggers an error in deno but no in node
crypto_1.default.createHash("MD5").update((0, stable_hash_1.default)(x)).digest("hex").substring(0, maxLength);
exports.hash = hash;

Sorry, the diff of this file is too big to display

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