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
91
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 61.0.0 to 62.0.0

5

esm/src/array.js

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

import { isPromise } from "./promise.js";
const firstTrue = (promises) => {

@@ -10,3 +11,3 @@ const newPromises = promises.map((p) => new Promise((resolve, reject) => p.then((v) => v && resolve(true), reject)));

const result = f(x);
if (result instanceof Promise) {
if (isPromise(result)) {
promises.push(result);

@@ -26,3 +27,3 @@ // @ts-expect-error cannot infer

const result = f(x);
if (result instanceof Promise) {
if (isPromise(result)) {
promises.push(result);

@@ -29,0 +30,0 @@ // @ts-expect-error cannot infer

13

esm/src/composition.js

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

import { currentLocation } from "./trace.js";
import { isPromise } from "./promise.js";
const pipeWithoutStack = (...fs) => ((...x) => reduce((v, f) => f(v), () => fs[0](...x))(fs.slice(1)));

@@ -17,3 +18,3 @@ const augmentException = (codeLocation) => (e) => {

const result = f(...x);
return (result instanceof Promise)
return (isPromise(result))
? result.catch((e) => {

@@ -49,10 +50,10 @@ if (e === undefined) {

// @ts-expect-error compiler cannot dynamically infer
return (result instanceof Promise) ? result.then(() => x) : x;
return (isPromise(result)) ? result.then(() => x) : x;
};
export const wrapSideEffect = (cleanup) => (f) => (...args) => {
const result = f(...args);
if (result instanceof Promise) {
if (isPromise(result)) {
return result.then((result) => {
const cleanUpResult = cleanup(...args);
return cleanUpResult instanceof Promise
return isPromise(cleanUpResult)
? cleanUpResult.then(() => result)

@@ -64,5 +65,3 @@ : result;

const cleanUpResult = cleanup(...args);
return cleanUpResult instanceof Promise
? cleanUpResult.then(() => result)
: result;
return isPromise(cleanUpResult) ? cleanUpResult.then(() => result) : result;
}

@@ -69,0 +68,0 @@ };

import { head, second } from "./array.js";
import { pipe } from "./composition.js";
import { filter } from "./filter.js";
import { isPromise } from "./promise.js";
export const ifElse = (predicate, fTrue, fFalse) => (...x) => {
const result = predicate(...x);
return result instanceof Promise
return isPromise(result)
? result.then((predicateResult) => predicateResult ? fTrue(...x) : fFalse(...x))

@@ -8,0 +9,0 @@ : result

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

@@ -13,3 +14,3 @@ console.log(currentLocation(3), x);

const output = f(...xs);
if (output instanceof Promise) {
if (isPromise(output)) {
return output.then((x) => {

@@ -28,3 +29,3 @@ console.log(codeLocation, x);

const output = f(...xs);
if (output instanceof Promise) {
if (isPromise(output)) {
return output.then((x) => {

@@ -44,3 +45,3 @@ console.log(codeLocation, x);

const output = f(...xs);
if (output instanceof Promise) {
if (isPromise(output)) {
return output.then((x) => {

@@ -57,3 +58,3 @@ return x;

const result = f(...x);
if (result instanceof Promise) {
if (isPromise(result)) {
return result.then((result) => {

@@ -83,3 +84,3 @@ const elapsed = getTimestampMilliseconds() - started;

const result = f(...x);
return result instanceof Promise
return isPromise(result)
? result.catch((e) => {

@@ -86,0 +87,0 @@ return fallback(e, ...x);

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

import { pairRight } from "./juxt.js";
import { isPromise } from "./promise.js";
export const filter = (f) =>

@@ -13,3 +14,3 @@ // @ts-expect-error typing head is hard.

const result = predicate(x);
if (result instanceof Promise) {
if (isPromise(result)) {
asyncResults.push(result.then((predicateResult) => new Promise((resolve, reject) => predicateResult ? resolve(x) : reject(new Error("failed check")))));

@@ -16,0 +17,0 @@ }

import { allmap, anymap, concat, zip } from "./array.js";
import { identity, pipe } from "./composition.js";
import { map } from "./map.js";
import { isPromise } from "./index.js";
export const juxt = (...fs) => (...x) => {

@@ -9,3 +10,3 @@ const result = [];

result.push(f(...x));
anyAsync = anyAsync || result[result.length - 1] instanceof Promise;
anyAsync = anyAsync || isPromise(result[result.length - 1]);
}

@@ -12,0 +13,0 @@ // @ts-expect-error reason=ts does not understand me :_(

import { AsyncFunction } from "./typing.js";
export declare const withLock: <Function_1 extends AsyncFunction>(lock: (...task: Parameters<Function_1>) => void | Promise<void>, unlock: (...task: Parameters<Function_1>) => void | Promise<void>, f: Function_1) => Function_1;
export declare const withLock: <F extends AsyncFunction>(lock: (...task: Parameters<F>) => void | Promise<void>, unlock: (...task: Parameters<F>) => void | Promise<void>, f: F) => F;
export declare const keepTryingEvery50ms: (f: () => boolean | Promise<boolean>) => Promise<void>;

@@ -4,0 +4,0 @@ export declare const makeLockWithId: <Key>(set: (_: Key) => boolean | Promise<boolean>) => (id: Key) => Promise<void>;

import { pipe } from "./composition.js";
import { reduce } from "./reduce.js";
import { isPromise } from "./promise.js";
// deno-lint-ignore no-explicit-any

@@ -10,5 +11,3 @@ export const map = (f) => (xs) => {

// @ts-expect-error ts cannot reason about this dynamic ternary
return (results.some((x) => x instanceof Promise)
? Promise.all(results)
: results);
return results.some(isPromise) ? Promise.all(results) : results;
};

@@ -15,0 +14,0 @@ export const mapCat = (f) =>

export declare const promiseAll: (promises: Promise<unknown>[]) => Promise<unknown[]>;
export declare const wrapPromise: <T>(x: T) => Promise<T>;
export declare const isPromise: (x: any) => boolean;
export declare const isPromise: (x: any) => x is Promise<any>;
type NullaryFunction = () => void | Promise<void>;
export declare const doInSequence: (head: NullaryFunction, ...rest: NullaryFunction[]) => Promise<void>;
export {};

@@ -6,3 +6,3 @@ // Cannot be made point free.

// deno-lint-ignore no-explicit-any
export const isPromise = (x) => x instanceof Promise;
export const isPromise = (x) => !!x?.then && !!x?.catch && !!x?.finally;
export const doInSequence = (head, ...rest) => wrapPromise(head()).then((x) => rest.length ? doInSequence(rest[0], ...rest.slice(1)) : x);

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

import { isPromise } from "./promise.js";
const reduceHelper = (reducer, s, xs, firstIndex) => {
let current = s;
for (let i = firstIndex; i < xs.length; i++) {
if (current instanceof Promise) {
if (isPromise(current)) {
return current.then((s) => reduceHelper(reducer, s, xs, i));

@@ -16,3 +17,3 @@ }

const keyX = key(x);
return ((keyS instanceof Promise || keyX instanceof Promise)
return ((isPromise(keyS) || isPromise(keyX))
? Promise.all([keyS, keyX]).then(([keyS, keyX]) => keyS < keyX ? s : x)

@@ -26,3 +27,3 @@ : key(s) < key(x)

const keyX = key(x);
return ((keyS instanceof Promise || keyX instanceof Promise)
return ((isPromise(keyS) || isPromise(keyX))
? Promise.all([keyS, keyX]).then(([keyS, keyX]) => keyS < keyX ? x : s)

@@ -29,0 +30,0 @@ : key(s) < key(x)

{
"name": "gamla",
"version": "61.0.0",
"version": "62.0.0",
"description": "Functional programming with async and type safety",

@@ -5,0 +5,0 @@ "repository": {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.slidingWindow = exports.enumerate = exports.drop = exports.sample = exports.take = exports.includedIn = exports.contains = exports.range = exports.sortKey = exports.sort = exports.sortCompare = exports.zip = exports.wrapArray = exports.nonempty = exports.empty = exports.last = exports.third = exports.second = exports.init = exports.head = exports.tail = exports.reverse = exports.concat = exports.unique = exports.uniqueBy = exports.length = exports.join = exports.all = exports.allmap = exports.any = exports.anymap = void 0;
const promise_js_1 = require("./promise.js");
const firstTrue = (promises) => {

@@ -13,3 +14,3 @@ const newPromises = promises.map((p) => new Promise((resolve, reject) => p.then((v) => v && resolve(true), reject)));

const result = f(x);
if (result instanceof Promise) {
if ((0, promise_js_1.isPromise)(result)) {
promises.push(result);

@@ -31,3 +32,3 @@ // @ts-expect-error cannot infer

const result = f(x);
if (result instanceof Promise) {
if ((0, promise_js_1.isPromise)(result)) {
promises.push(result);

@@ -34,0 +35,0 @@ // @ts-expect-error cannot infer

@@ -8,2 +8,3 @@ "use strict";

const trace_js_1 = require("./trace.js");
const promise_js_1 = require("./promise.js");
const pipeWithoutStack = (...fs) => ((...x) => (0, reduce_js_1.reduce)((v, f) => f(v), () => fs[0](...x))(fs.slice(1)));

@@ -20,3 +21,3 @@ const augmentException = (codeLocation) => (e) => {

const result = f(...x);
return (result instanceof Promise)
return ((0, promise_js_1.isPromise)(result))
? result.catch((e) => {

@@ -57,3 +58,3 @@ if (e === undefined) {

// @ts-expect-error compiler cannot dynamically infer
return (result instanceof Promise) ? result.then(() => x) : x;
return ((0, promise_js_1.isPromise)(result)) ? result.then(() => x) : x;
};

@@ -63,6 +64,6 @@ exports.sideEffect = sideEffect;

const result = f(...args);
if (result instanceof Promise) {
if ((0, promise_js_1.isPromise)(result)) {
return result.then((result) => {
const cleanUpResult = cleanup(...args);
return cleanUpResult instanceof Promise
return (0, promise_js_1.isPromise)(cleanUpResult)
? cleanUpResult.then(() => result)

@@ -74,5 +75,3 @@ : result;

const cleanUpResult = cleanup(...args);
return cleanUpResult instanceof Promise
? cleanUpResult.then(() => result)
: result;
return (0, promise_js_1.isPromise)(cleanUpResult) ? cleanUpResult.then(() => result) : result;
}

@@ -79,0 +78,0 @@ };

@@ -7,5 +7,6 @@ "use strict";

const filter_js_1 = require("./filter.js");
const promise_js_1 = require("./promise.js");
const ifElse = (predicate, fTrue, fFalse) => (...x) => {
const result = predicate(...x);
return result instanceof Promise
return (0, promise_js_1.isPromise)(result)
? result.then((predicateResult) => predicateResult ? fTrue(...x) : fFalse(...x))

@@ -12,0 +13,0 @@ : result

@@ -7,2 +7,3 @@ "use strict";

const composition_js_1 = require("./composition.js");
const promise_js_1 = require("./promise.js");
const sideLog = (x) => {

@@ -18,3 +19,3 @@ console.log((0, trace_js_1.currentLocation)(3), x);

const output = f(...xs);
if (output instanceof Promise) {
if ((0, promise_js_1.isPromise)(output)) {
return output.then((x) => {

@@ -34,3 +35,3 @@ console.log(codeLocation, x);

const output = f(...xs);
if (output instanceof Promise) {
if ((0, promise_js_1.isPromise)(output)) {
return output.then((x) => {

@@ -51,3 +52,3 @@ console.log(codeLocation, x);

const output = f(...xs);
if (output instanceof Promise) {
if ((0, promise_js_1.isPromise)(output)) {
return output.then((x) => {

@@ -65,3 +66,3 @@ return x;

const result = f(...x);
if (result instanceof Promise) {
if ((0, promise_js_1.isPromise)(result)) {
return result.then((result) => {

@@ -94,3 +95,3 @@ const elapsed = getTimestampMilliseconds() - started;

const result = f(...x);
return result instanceof Promise
return (0, promise_js_1.isPromise)(result)
? result.catch((e) => {

@@ -97,0 +98,0 @@ return fallback(e, ...x);

@@ -8,2 +8,3 @@ "use strict";

const juxt_js_1 = require("./juxt.js");
const promise_js_1 = require("./promise.js");
const filter = (f) =>

@@ -17,3 +18,3 @@ // @ts-expect-error typing head is hard.

const result = predicate(x);
if (result instanceof Promise) {
if ((0, promise_js_1.isPromise)(result)) {
asyncResults.push(result.then((predicateResult) => new Promise((resolve, reject) => predicateResult ? resolve(x) : reject(new Error("failed check")))));

@@ -20,0 +21,0 @@ }

@@ -7,2 +7,3 @@ "use strict";

const map_js_1 = require("./map.js");
const index_js_1 = require("./index.js");
const juxt = (...fs) => (...x) => {

@@ -13,3 +14,3 @@ const result = [];

result.push(f(...x));
anyAsync = anyAsync || result[result.length - 1] instanceof Promise;
anyAsync = anyAsync || (0, index_js_1.isPromise)(result[result.length - 1]);
}

@@ -16,0 +17,0 @@ // @ts-expect-error reason=ts does not understand me :_(

import { AsyncFunction } from "./typing.js";
export declare const withLock: <Function_1 extends AsyncFunction>(lock: (...task: Parameters<Function_1>) => void | Promise<void>, unlock: (...task: Parameters<Function_1>) => void | Promise<void>, f: Function_1) => Function_1;
export declare const withLock: <F extends AsyncFunction>(lock: (...task: Parameters<F>) => void | Promise<void>, unlock: (...task: Parameters<F>) => void | Promise<void>, f: F) => F;
export declare const keepTryingEvery50ms: (f: () => boolean | Promise<boolean>) => Promise<void>;

@@ -4,0 +4,0 @@ export declare const makeLockWithId: <Key>(set: (_: Key) => boolean | Promise<boolean>) => (id: Key) => Promise<void>;

@@ -6,2 +6,3 @@ "use strict";

const reduce_js_1 = require("./reduce.js");
const promise_js_1 = require("./promise.js");
// deno-lint-ignore no-explicit-any

@@ -14,5 +15,3 @@ const map = (f) => (xs) => {

// @ts-expect-error ts cannot reason about this dynamic ternary
return (results.some((x) => x instanceof Promise)
? Promise.all(results)
: results);
return results.some(promise_js_1.isPromise) ? Promise.all(results) : results;
};

@@ -19,0 +18,0 @@ exports.map = map;

export declare const promiseAll: (promises: Promise<unknown>[]) => Promise<unknown[]>;
export declare const wrapPromise: <T>(x: T) => Promise<T>;
export declare const isPromise: (x: any) => boolean;
export declare const isPromise: (x: any) => x is Promise<any>;
type NullaryFunction = () => void | Promise<void>;
export declare const doInSequence: (head: NullaryFunction, ...rest: NullaryFunction[]) => Promise<void>;
export {};

@@ -11,5 +11,5 @@ "use strict";

// deno-lint-ignore no-explicit-any
const isPromise = (x) => x instanceof Promise;
const isPromise = (x) => !!x?.then && !!x?.catch && !!x?.finally;
exports.isPromise = isPromise;
const doInSequence = (head, ...rest) => (0, exports.wrapPromise)(head()).then((x) => rest.length ? (0, exports.doInSequence)(rest[0], ...rest.slice(1)) : x);
exports.doInSequence = doInSequence;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.max = exports.min = exports.reduce = void 0;
const promise_js_1 = require("./promise.js");
const reduceHelper = (reducer, s, xs, firstIndex) => {
let current = s;
for (let i = firstIndex; i < xs.length; i++) {
if (current instanceof Promise) {
if ((0, promise_js_1.isPromise)(current)) {
return current.then((s) => reduceHelper(reducer, s, xs, i));

@@ -20,3 +21,3 @@ }

const keyX = key(x);
return ((keyS instanceof Promise || keyX instanceof Promise)
return (((0, promise_js_1.isPromise)(keyS) || (0, promise_js_1.isPromise)(keyX))
? Promise.all([keyS, keyX]).then(([keyS, keyX]) => keyS < keyX ? s : x)

@@ -31,3 +32,3 @@ : key(s) < key(x)

const keyX = key(x);
return ((keyS instanceof Promise || keyX instanceof Promise)
return (((0, promise_js_1.isPromise)(keyS) || (0, promise_js_1.isPromise)(keyX))
? Promise.all([keyS, keyX]).then(([keyS, keyX]) => keyS < keyX ? x : s)

@@ -34,0 +35,0 @@ : key(s) < key(x)

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