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

fp-ts-quickcheck

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fp-ts-quickcheck - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

dist/cjs/gen.d.ts

14

dist/cjs/arbitrary.d.ts

@@ -9,3 +9,4 @@ import { Applicative1 } from "fp-ts/lib/Applicative";

import { Refinement } from "fp-ts/lib/Refinement";
import { generator as gen } from "./modules";
import * as gen from "./gen";
import * as shrinkable from "./shrink";
import { EnforceNonEmptyRecord } from "./utils";

@@ -24,3 +25,4 @@ /**

export interface Arbitrary<A> {
readonly arbitrary: gen.Gen<A>;
readonly generate: gen.Gen<A>;
readonly shrink: shrinkable.Shrink<A>;
}

@@ -74,3 +76,3 @@ declare module "fp-ts/HKT" {

*/
export declare function fromGen<A>(gen: gen.Gen<A>): Arbitrary<A>;
export declare function fromGen<A>(gen: gen.Gen<A>, shrink?: shrinkable.Shrink<A>): Arbitrary<A>;
/**

@@ -108,3 +110,3 @@ * @category Constructors

export declare function partial<T extends Record<string, unknown>>(arbitraries: {
[P in keyof T]: Arbitrary<T[P]>;
readonly [P in keyof T]: Arbitrary<T[P]>;
}): Arbitrary<Partial<T>>;

@@ -176,2 +178,6 @@ /**

/**
* @category Destructors
*/
export declare function toShrink<A>(fa: Arbitrary<A>): shrinkable.Shrink<A>;
/**
* @category Primitives

@@ -178,0 +184,0 @@ */

@@ -13,2 +13,21 @@ "use strict";

};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __read = (this && this.__read) || function (o, n) {

@@ -40,3 +59,3 @@ var m = typeof Symbol === "function" && o[Symbol.iterator];

Object.defineProperty(exports, "__esModule", { value: true });
exports.stringNonempty = exports.boolean = exports.toGen = exports.union = exports.struct = exports.tuple = exports.mutable = exports.readonly = exports.vector = exports.array = exports.filter = exports.lazy = exports.partial = exports.nullable = exports.string = exports.character = exports.float = exports.int = exports.fromGen = exports.Chain = exports.Applicative = exports.Apply = exports.Functor = exports.Pointed = exports.chain = exports.ap = exports.map = exports.of = exports.URI = void 0;
exports.stringNonempty = exports.boolean = exports.toShrink = exports.toGen = exports.union = exports.struct = exports.tuple = exports.mutable = exports.readonly = exports.vector = exports.array = exports.filter = exports.lazy = exports.partial = exports.nullable = exports.string = exports.character = exports.float = exports.int = exports.fromGen = exports.Chain = exports.Applicative = exports.Apply = exports.Functor = exports.Pointed = exports.chain = exports.ap = exports.map = exports.of = exports.URI = void 0;
/**

@@ -51,3 +70,6 @@ * The `Arbitrary` typeclass represents a value that can be generated and shrunk.

var modules_1 = require("./modules");
var gen = __importStar(require("./gen"));
var fp_ts_2 = require("./modules/fp-ts");
var shrinkable = __importStar(require("./shrink"));
var utils_1 = require("./utils");
/**

@@ -57,2 +79,3 @@ * @category Model

exports.URI = "Arbitrary";
var shrink_ = shrinkable.zero;
// PIPEABLES

@@ -62,3 +85,6 @@ /**

*/
var of = function (a) { return ({ arbitrary: fp_ts_2.state.of(a) }); };
var of = function (a) { return ({
generate: fp_ts_2.state.of(a),
shrink: shrink_(),
}); };
exports.of = of;

@@ -69,3 +95,4 @@ /**

var map = function (f) { return function (fa) { return ({
arbitrary: (0, function_1.pipe)(fa.arbitrary, fp_ts_2.state.map(f)),
generate: (0, function_1.pipe)(fa.generate, gen.map(f)),
shrink: (0, function_1.pipe)(fa.shrink, shrinkable.map(f)),
}); }; };

@@ -77,3 +104,4 @@ exports.map = map;

var ap = function (fa) { return function (fab) { return ({
arbitrary: (0, function_1.pipe)(fab.arbitrary, fp_ts_2.state.ap(fa.arbitrary)),
generate: (0, function_1.pipe)(fab.generate, fp_ts_2.state.ap(fa.generate)),
shrink: (0, function_1.pipe)(fab.shrink, shrinkable.ap(fa.shrink)),
}); }; };

@@ -85,3 +113,4 @@ exports.ap = ap;

var chain = function (f) { return function (fa) { return ({
arbitrary: (0, function_1.pipe)(fa.arbitrary, fp_ts_2.state.chain((0, function_1.flow)(f, function (b) { return b.arbitrary; }))),
generate: (0, function_1.pipe)(fa.generate, fp_ts_2.state.chain((0, function_1.flow)(f, function (b) { return b.generate; }))),
shrink: (0, function_1.pipe)(fa.shrink, shrinkable.chain((0, function_1.flow)(f, function (b) { return b.shrink; }))),
}); }; };

@@ -117,4 +146,5 @@ exports.chain = chain;

*/
function fromGen(gen) {
return { arbitrary: gen };
function fromGen(gen, shrink) {
if (shrink === void 0) { shrink = shrinkable.zero(); }
return { generate: gen, shrink: shrink };
}

@@ -126,3 +156,10 @@ exports.fromGen = fromGen;

function int(options) {
return { arbitrary: modules_1.generator.int(options) };
return (0, function_1.pipe)(fp_ts_1.identity.Do, fp_ts_1.identity.bind("generate", function () { return gen.int(options); }), fp_ts_1.identity.bind("shrink", function (_a) {
var generate = _a.generate;
return (0, function_1.pipe)(generate, fp_ts_2.state.map(function (int) {
return int === 0
? modules_1.iterable.zero()
: (0, function_1.pipe)(int < 0 ? modules_1.iterable.of(Math.abs(int)) : modules_1.iterable.zero(), modules_1.iterable.alt(function () { return modules_1.iterable.of(0); }), modules_1.iterable.alt(function () { return (0, utils_1.rightDichotomy)(int); }));
}));
}));
}

@@ -134,3 +171,3 @@ exports.int = int;

function float(options) {
return { arbitrary: modules_1.generator.float(options) };
return { generate: gen.float(options), shrink: shrink_() };
}

@@ -144,7 +181,7 @@ exports.float = float;

*/
exports.character = (0, function_1.flow)(modules_1.generator.char, fromGen);
exports.character = (0, function_1.flow)(gen.char, fromGen);
/**
* @category Constructors
*/
exports.string = (0, function_1.flow)(modules_1.generator.string, fromGen);
exports.string = (0, function_1.flow)(gen.string, fromGen);
// COMBINATORS

@@ -165,5 +202,9 @@ /**

return {
arbitrary: (0, function_1.pipe)(fp_ts_2.state.get(), fp_ts_2.state.map(function (s) {
generate: (0, function_1.pipe)(fp_ts_2.state.get(), fp_ts_2.state.map(function (s) {
return (0, function_1.pipe)(arbitraries, fp_ts_1.readonlyRecord.fromRecord, fp_ts_1.readonlyRecord.map((0, function_1.flow)(exports.nullable, toGen, fp_ts_2.state.evaluate(s))), fp_ts_1.readonlyRecord.filterMap(fp_ts_1.option.fromNullable), function (a) { return (0, function_1.unsafeCoerce)(a); });
})),
//
shrink: (0, function_1.pipe)(fp_ts_2.state.get(), fp_ts_2.state.map(function (s) {
return (0, function_1.pipe)(arbitraries, fp_ts_1.readonlyRecord.fromRecord, fp_ts_1.readonlyRecord.map((0, function_1.flow)(exports.nullable, toShrink, fp_ts_2.state.evaluate(s))), fp_ts_1.readonlyRecord.filterMap(fp_ts_1.option.fromPredicate(modules_1.iterable.some(function (a) { return a != null; }))), function (a) { return (0, function_1.unsafeCoerce)(a); });
})),
};

@@ -183,3 +224,6 @@ }

function lazy(lazy) {
return { arbitrary: function (s) { return lazy().arbitrary(s); } };
return {
generate: function (s) { return lazy().generate(s); },
shrink: function (s) { return lazy().shrink(s); },
};
}

@@ -189,5 +233,6 @@ exports.lazy = lazy;

return function (fa) { return ({
arbitrary: (0, function_1.pipe)(fa.arbitrary, fp_ts_2.state.chain(fp_ts_2.state.chainRec((0, function_1.flow)(fp_ts_1.either.fromPredicate(predicate, function_1.identity), fp_ts_1.either.map(function (a) { return modules_1.generator.of(fp_ts_1.either.right(a)); }), fp_ts_1.either.getOrElse(function () {
return (0, function_1.pipe)(fa.arbitrary, fp_ts_2.state.apFirst(modules_1.generator.nextSeed), modules_1.generator.map(function (e) { return fp_ts_1.either.left(e); }));
generate: (0, function_1.pipe)(fa.generate, fp_ts_2.state.chain(fp_ts_2.state.chainRec((0, function_1.flow)(fp_ts_1.either.fromPredicate(predicate, function_1.identity), fp_ts_1.either.map(function (a) { return gen.of(fp_ts_1.either.right(a)); }), fp_ts_1.either.getOrElse(function () {
return (0, function_1.pipe)(fa.generate, fp_ts_2.state.apFirst(gen.nextSeed), gen.map(function (e) { return fp_ts_1.either.left(e); }));
}))))),
shrink: shrink_(),
}); };

@@ -204,3 +249,4 @@ }

return {
arbitrary: modules_1.generator.arrayOf(arbitrary.arbitrary),
generate: gen.arrayOf(arbitrary.generate),
shrink: shrink_(),
};

@@ -215,3 +261,4 @@ }

return function (fa) { return ({
arbitrary: modules_1.generator.vectorOf(size)(fa.arbitrary),
generate: gen.vectorOf(size)(fa.generate),
shrink: shrink_(),
}); };

@@ -258,5 +305,10 @@ }

}
return {
arbitrary: modules_1.generator.oneOf((0, function_1.pipe)(arbitraries, fp_ts_1.nonEmptyArray.map(function (arbitrary) { return arbitrary.arbitrary; }))),
};
return (0, function_1.pipe)(fp_ts_1.identity.Do, fp_ts_1.identity.bind("generate", function () {
return gen.oneOf((0, function_1.pipe)(arbitraries, fp_ts_1.nonEmptyArray.map(function (arbitrary) { return arbitrary.generate; })));
}), fp_ts_1.identity.bind("shrink", function (_a) {
var generate = _a.generate;
return (0, function_1.pipe)(generate,
// get smallest value
gen.map(function () { return modules_1.iterable.zero(); }));
}));
}

@@ -269,5 +321,12 @@ exports.union = union;

function toGen(fa) {
return fa.arbitrary;
return fa.generate;
}
exports.toGen = toGen;
/**
* @category Destructors
*/
function toShrink(fa) {
return fa.shrink;
}
exports.toShrink = toShrink;
//PRIMITIVES

@@ -277,5 +336,8 @@ /**

*/
exports.boolean = {
arbitrary: modules_1.generator.boolean,
};
exports.boolean = (0, function_1.pipe)(fp_ts_1.identity.Do, fp_ts_1.identity.bind("generate", function () { return gen.boolean; }),
// true, false
fp_ts_1.identity.bind("shrink", function (_a) {
var generate = _a.generate;
return (0, function_1.pipe)(generate, gen.map(function (boolean) { return (boolean ? modules_1.iterable.of(false) : modules_1.iterable.zero()); }));
}));
function stringNonempty(options) {

@@ -282,0 +344,0 @@ return (0, function_1.pipe)((0, exports.string)(options), filter(function (string) { return string.length > 0; }));

@@ -10,3 +10,3 @@ /**

import { Arbitrary } from "./arbitrary";
import { generator as gen } from "./modules";
import * as gen from "./gen";
/**

@@ -13,0 +13,0 @@ * @category Model

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -10,3 +29,3 @@ exports.reader = exports.either = exports.option = exports.boolean = exports.ordering = exports.contramap = exports.Contravariant = exports.URI = void 0;

var function_1 = require("fp-ts/lib/function");
var modules_1 = require("./modules");
var gen = __importStar(require("./gen"));
/**

@@ -30,4 +49,4 @@ * @category Model

coarbitrary: function (ordering) {
return modules_1.generator.chainFirst(function () {
return modules_1.generator.variant(ordering === 1 ? 0 : ordering === 0 ? 1 : 2);
return gen.chainFirst(function () {
return gen.variant(ordering === 1 ? 0 : ordering === 0 ? 1 : 2);
});

@@ -37,8 +56,8 @@ },

exports.boolean = {
coarbitrary: function (bool) { return modules_1.generator.chainFirst(function () { return modules_1.generator.variant(bool ? 1 : 0); }); },
coarbitrary: function (bool) { return gen.chainFirst(function () { return gen.variant(bool ? 1 : 0); }); },
};
function option(fa) {
return {
coarbitrary: fp_ts_1.option.fold(function () { return modules_1.generator.chainFirst(function () { return modules_1.generator.variant(0); }); }, function (a) {
return (0, function_1.flow)(fa.coarbitrary(a), modules_1.generator.chainFirst(function () { return modules_1.generator.variant(1); }));
coarbitrary: fp_ts_1.option.fold(function () { return gen.chainFirst(function () { return gen.variant(0); }); }, function (a) {
return (0, function_1.flow)(fa.coarbitrary(a), gen.chainFirst(function () { return gen.variant(1); }));
}),

@@ -51,5 +70,5 @@ };

coarbitrary: fp_ts_1.either.fold(function (e) {
return (0, function_1.flow)(fe.coarbitrary(e), modules_1.generator.chainFirst(function () { return modules_1.generator.variant(0); }));
return (0, function_1.flow)(fe.coarbitrary(e), gen.chainFirst(function () { return gen.variant(0); }));
}, function (a) {
return (0, function_1.flow)(fa.coarbitrary(a), modules_1.generator.chainFirst(function () { return modules_1.generator.variant(1); }));
return (0, function_1.flow)(fa.coarbitrary(a), gen.chainFirst(function () { return gen.variant(1); }));
}),

@@ -62,3 +81,3 @@ };

coarbitrary: function (fea) { return function (fr) {
return (0, function_1.pipe)(ge.arbitrary, modules_1.generator.map(fea), modules_1.generator.chain(function (a) { return (0, function_1.pipe)(fr, fa.coarbitrary(a)); }));
return (0, function_1.pipe)(ge.generate, gen.map(fea), gen.chain(function (a) { return (0, function_1.pipe)(fr, fa.coarbitrary(a)); }));
}; },

@@ -65,0 +84,0 @@ };

export * as arbitrary from "./arbitrary";
export * as coarbitrary from "./coarbitrary";
export * as quickcheck from "./quickcheck";
export * as gen from "./gen";

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.quickcheck = exports.coarbitrary = exports.arbitrary = void 0;
exports.gen = exports.quickcheck = exports.coarbitrary = exports.arbitrary = void 0;
exports.arbitrary = __importStar(require("./arbitrary"));
exports.coarbitrary = __importStar(require("./coarbitrary"));
exports.quickcheck = __importStar(require("./quickcheck"));
exports.gen = __importStar(require("./gen"));

@@ -57,6 +57,10 @@ "use strict";

exports.ChainRec = __assign(__assign({}, State_1.Chain), { chainRec: function (a, f) { return function (s) {
// eslint-disable-next-line functional/no-let
var _a = __read(f(a)(s), 2), _ea = _a[0], _state = _a[1];
// eslint-disable-next-line functional/no-loop-statement
while (E.isLeft(_ea)) {
var result = f(_ea.left)(_state);
// eslint-disable-next-line functional/no-expression-statement
_ea = result[0];
// eslint-disable-next-line functional/no-expression-statement
_state = result[1];

@@ -63,0 +67,0 @@ }

export * as iterable from "./iterable";
export * as generator from "./generator";
export * as lcg from "./lcg";
export * as monadRecIO from "./monad-rec-io";

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.monadRecIO = exports.lcg = exports.generator = exports.iterable = void 0;
exports.monadRecIO = exports.lcg = exports.iterable = void 0;
exports.iterable = __importStar(require("./iterable"));
exports.generator = __importStar(require("./generator"));
exports.lcg = __importStar(require("./lcg"));
exports.monadRecIO = __importStar(require("./monad-rec-io"));

@@ -10,2 +10,3 @@ /**

import { Compactable1 } from "fp-ts/lib/Compactable";
import { Endomorphism } from "fp-ts/lib/Endomorphism";
import { FilterableWithIndex1, PredicateWithIndex, RefinementWithIndex } from "fp-ts/lib/FilterableWithIndex";

@@ -18,2 +19,5 @@ import { FoldableWithIndex1 } from "fp-ts/lib/FoldableWithIndex";

import { Refinement } from "fp-ts/lib/Refinement";
import { PipeableTraverse1 } from "fp-ts/lib/Traversable";
import { PipeableTraverseWithIndex1 } from "fp-ts/lib/TraversableWithIndex";
import { TraversableWithIndex1 } from "fp-ts/lib/TraversableWithIndex";
import { Zero1 } from "fp-ts/lib/Zero";

@@ -105,2 +109,3 @@ /**

export declare const Alt: Alt1<URI>;
export declare const alt: <A>(that: import("fp-ts/lib/function").Lazy<Iterable<A>>) => (fa: Iterable<A>) => Iterable<A>;
/**

@@ -111,2 +116,3 @@ * @category instances

export declare const Zero: Zero1<URI>;
export declare const zero: <A>() => Iterable<A>;
/**

@@ -117,2 +123,3 @@ * @category instances

export declare const Compactable: Compactable1<URI>;
export declare const flatten: <A>(mma: Iterable<Iterable<A>>) => Iterable<A>, ap: <A>(fa: Iterable<A>) => <B>(fab: Iterable<(a: A) => B>) => Iterable<B>, apFirst: <B>(fb: Iterable<B>) => <A>(fa: Iterable<A>) => Iterable<A>, apSecond: <B>(fb: Iterable<B>) => <A>(fa: Iterable<A>) => Iterable<B>;
/**

@@ -128,2 +135,5 @@ * @category instances

export declare const FoldableWithIndex: FoldableWithIndex1<URI, number>;
export declare const TraversableWithIndex: TraversableWithIndex1<URI, number>;
export declare const traverseWithIndex: PipeableTraverseWithIndex1<URI, number>;
export declare const traverse: PipeableTraverse1<URI>;
/**

@@ -181,1 +191,4 @@ * Takes a function returning an `Option` and keeps it until it contains `None`.

export declare function skip(count: number): <A>(fa: Iterable<A>) => Iterable<A>;
export declare function some<A, B extends A>(f: Predicate<A> | Refinement<A, B>): (fa: Iterable<A>) => fa is Iterable<B>;
export declare function every<A, B extends A>(f: Predicate<A> | Refinement<A, B>): (fa: Iterable<A>) => fa is Iterable<B>;
export declare function iterate<A>(f: Endomorphism<A>): (a: A) => Iterable<A>;

@@ -51,4 +51,5 @@ "use strict";

};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.skip = exports.skipWhile = exports.skipWhileWithIndex = exports.take = exports.takeWhile = exports.takeWhileWithIndex = exports.takeWhileMapWithIndex = exports.FoldableWithIndex = exports.FilterableWithIndex = exports.Compactable = exports.Zero = exports.Alt = exports.Monad = exports.Chain = exports.Applicative = exports.Apply = exports.FunctorWithIndex = exports.Pointed = exports.map = exports.mapWithIndex = exports.toReadonlyArray = exports.fromIterable = exports.getEq = exports.of = exports.URI = void 0;
exports.iterate = exports.every = exports.some = exports.skip = exports.skipWhile = exports.skipWhileWithIndex = exports.take = exports.takeWhile = exports.takeWhileWithIndex = exports.takeWhileMapWithIndex = exports.traverse = exports.traverseWithIndex = exports.TraversableWithIndex = exports.FoldableWithIndex = exports.FilterableWithIndex = exports.apSecond = exports.apFirst = exports.ap = exports.flatten = exports.Compactable = exports.zero = exports.Zero = exports.alt = exports.Alt = exports.Monad = exports.Chain = exports.Applicative = exports.Apply = exports.FunctorWithIndex = exports.Pointed = exports.map = exports.mapWithIndex = exports.toReadonlyArray = exports.fromIterable = exports.getEq = exports.of = exports.URI = void 0;
/**

@@ -59,2 +60,3 @@ * @since 0.12.0

var function_1 = require("fp-ts/lib/function");
var pipeable_1 = require("fp-ts/lib/pipeable");
/**

@@ -424,2 +426,3 @@ * @category Model

} });
exports.alt = (0, pipeable_1.pipeable)(exports.Alt).alt;
/**

@@ -439,2 +442,3 @@ * @category instances

};
exports.zero = exports.Zero.zero;
var _filterMapWithIndex = function (fa, f) {

@@ -499,2 +503,3 @@ var _a;

};
exports.flatten = (_a = (0, pipeable_1.pipeable)(exports.Chain), _a.flatten), exports.ap = _a.ap, exports.apFirst = _a.apFirst, exports.apSecond = _a.apSecond;
/**

@@ -562,2 +567,32 @@ * @category instances

};
var _traverseWithIndex = function (F) {
return function (ta, f) {
return (0, function_1.pipe)(ta, toReadonlyArray, fp_ts_1.readonlyArray.traverseWithIndex(F)(f));
};
};
exports.TraversableWithIndex = __assign(__assign(__assign({}, exports.FunctorWithIndex), exports.FoldableWithIndex), { traverseWithIndex: _traverseWithIndex, traverse: function (F) {
return function (ta, f) {
return _traverseWithIndex(F)(ta, function (i, a) { return f(a); });
};
}, sequence: function (F) {
return function (ta) {
return _traverseWithIndex(F)(ta, function (i, fa) { return fa; });
};
} });
var traverseWithIndex = function (F) {
return function (f) {
return function (ta) {
return _traverseWithIndex(F)(ta, f);
};
};
};
exports.traverseWithIndex = traverseWithIndex;
var traverse = function (F) {
return function (f) {
return function (ta) {
return _traverseWithIndex(F)(ta, function (i, a) { return f(a); });
};
};
};
exports.traverse = traverse;
/**

@@ -734,4 +769,81 @@ * Takes a function returning an `Option` and keeps it until it contains `None`.

function skip(count) {
return skipWhileWithIndex(function (i) { return i < count; });
return skipWhileWithIndex(function (i) { return i < count - 1; });
}
exports.skip = skip;
function some(f) {
return function (fa) {
var e_12, _a;
try {
// eslint-disable-next-line functional/no-loop-statement
for (var fa_9 = __values(fa), fa_9_1 = fa_9.next(); !fa_9_1.done; fa_9_1 = fa_9.next()) {
var a = fa_9_1.value;
// eslint-disable-next-line functional/no-conditional-statement
if (f(a))
return true;
}
}
catch (e_12_1) { e_12 = { error: e_12_1 }; }
finally {
try {
if (fa_9_1 && !fa_9_1.done && (_a = fa_9.return)) _a.call(fa_9);
}
finally { if (e_12) throw e_12.error; }
}
return false;
};
}
exports.some = some;
function every(f) {
return function (fa) {
var e_13, _a;
try {
// eslint-disable-next-line functional/no-loop-statement
for (var fa_10 = __values(fa), fa_10_1 = fa_10.next(); !fa_10_1.done; fa_10_1 = fa_10.next()) {
var a = fa_10_1.value;
// eslint-disable-next-line functional/no-conditional-statement
if (!f(a))
return false;
}
}
catch (e_13_1) { e_13 = { error: e_13_1 }; }
finally {
try {
if (fa_10_1 && !fa_10_1.done && (_a = fa_10.return)) _a.call(fa_10);
}
finally { if (e_13) throw e_13.error; }
}
return true;
};
}
exports.every = every;
function iterate(f) {
return function (a) {
var _a;
return (_a = {},
_a[Symbol.iterator] = function () {
var a_;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
a_ = a;
_a.label = 1;
case 1:
if (!true) return [3 /*break*/, 3];
// eslint-disable-next-line functional/no-expression-statement
return [4 /*yield*/, a_
// eslint-disable-next-line functional/no-expression-statement
];
case 2:
// eslint-disable-next-line functional/no-expression-statement
_a.sent();
// eslint-disable-next-line functional/no-expression-statement
a_ = f(a_);
return [3 /*break*/, 1];
case 3: return [2 /*return*/];
}
});
},
_a);
};
}
exports.iterate = iterate;

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

return M.fromIO(function () {
// eslint-disable-next-line functional/no-throw-statement
throw failure;

@@ -49,3 +50,4 @@ });

});
// eslint-disable-next-line functional/no-return-void
exports.sync = (0, function_1.flow)(exports.io, function (io) { return io(); });
exports.async = (0, function_1.flow)(exports.task, function (a) { return a(); });

@@ -27,4 +27,6 @@ "use strict";

var Arbitrary = _a.Arbitrary, Testable = _a.Testable, property = _a.property;
return (0, function_1.pipe)(Arbitrary.arbitrary, S.map(Testable.test), S.ap(S.of(property)), S.bindTo("resultM"), S.apS("newSeed", S.gets(function (genState) { return genState.newSeed; })));
return (0, function_1.pipe)(Arbitrary.generate, S.chain(function (value) {
return (0, function_1.pipe)(S.get(), S.map(function (seedState) { return Testable.test({ property: property, value: value, seedState: seedState }); }));
}), S.bindTo("resultM"), S.apS("newSeed", S.gets(function (genState) { return genState.newSeed; })));
}
exports.test = test;

@@ -1,12 +0,18 @@

import { identity as I, io as IO, option as O, task as T } from "fp-ts";
import { identity as I, io as IO, option as O, reader, task as T } from "fp-ts";
import { HKT, Kind, Kind2, URIS, URIS2 } from "fp-ts/HKT";
import * as gen from "./gen";
export interface TestableOptions<I, A> {
readonly property: reader.Reader<I, A>;
readonly value: I;
readonly seedState: gen.GenState;
}
export declare type Result = O.Option<unknown>;
export interface Testable<F, A> {
readonly test: <I>(value: I) => (property: (value: I) => A) => HKT<F, Result>;
readonly test: <I>(options: TestableOptions<I, A>) => HKT<F, Result>;
}
export interface Testable1<F extends URIS, A> {
readonly test: <I>(value: I) => (property: (value: I) => A) => Kind<F, Result>;
readonly test: <I>(options: TestableOptions<I, A>) => Kind<F, Result>;
}
export interface Testable2<F extends URIS2, E, A> {
readonly test: <I>(value: I) => (property: (value: I) => A) => Kind2<F, E, Result>;
readonly test: <I>(options: TestableOptions<I, A>) => Kind2<F, E, Result>;
}

@@ -13,0 +19,0 @@ export declare const boolean: Testable1<I.URI, boolean>;

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

exports.boolean = {
test: function (value) { return function (property) {
test: function (_a) {
var property = _a.property, value = _a.value;
return property(value)

@@ -18,13 +19,15 @@ ? fp_ts_1.option.none

}));
}; },
},
};
exports.assertionSync = {
test: function (value) { return function (property) {
test: function (_a) {
var property = _a.property, value = _a.value;
return (0, function_1.pipe)(value, fp_ts_1.ioEither.tryCatchK(property, function (e) { return e; }), fp_ts_1.ioEither.match(fp_ts_1.option.some, fp_ts_1.option.zero));
}; },
},
};
exports.assertionAsync = {
test: function (value) { return function (property) {
test: function (_a) {
var property = _a.property, value = _a.value;
return (0, function_1.pipe)(value, fp_ts_1.taskEither.tryCatchK(property, function (e) { return e; }), fp_ts_1.taskEither.match(fp_ts_1.option.some, fp_ts_1.option.zero));
}; },
},
};

@@ -43,3 +46,4 @@ var fromMain = function (property) {

exports.assertion = {
test: function (value) { return function (property) {
test: function (_a) {
var property = _a.property, value = _a.value;
return (0, function_1.pipe)(fromMain(property)(value), fp_ts_1.taskEither.chainEitherKW(fp_ts_1.either.fromPredicate(function (a) { return typeof a !== "boolean" || a; }, function () {

@@ -53,3 +57,3 @@ return new assert_1.AssertionError({

})), fp_ts_1.taskEither.match(fp_ts_1.option.some, fp_ts_1.option.zero));
}; },
},
};

@@ -8,1 +8,3 @@ import { either as E } from "fp-ts";

export declare function tailRecM<M>(M: Monad<M>): <A, B>(f: (a: A) => HKT<M, E.Either<A, B>>) => (fa: HKT<M, A>) => HKT<M, B>;
export declare const quot: (x: number, y: number) => number;
export declare const rightDichotomy: (n: number) => Iterable<number>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tailRecM = void 0;
exports.rightDichotomy = exports.quot = exports.tailRecM = void 0;
var fp_ts_1 = require("fp-ts");
var function_1 = require("fp-ts/lib/function");
var modules_1 = require("./modules");
/**

@@ -22,1 +23,7 @@ * @summary

exports.tailRecM = tailRecM;
var quot = function (x, y) { return Math.floor(x / y); };
exports.quot = quot;
var rightDichotomy = function (n) {
return (0, function_1.pipe)(n, modules_1.iterable.iterate(function (n) { return (0, exports.quot)(n, 2); }), modules_1.iterable.skip(1), modules_1.iterable.map(function (i) { return n - i; }), modules_1.iterable.takeWhile(function (m) { return Math.abs(m) < Math.abs(n); }));
};
exports.rightDichotomy = rightDichotomy;
{
"name": "fp-ts-quickcheck",
"main": "dist/cjs/index.js",
"module": "dist/es6/index.js",
"module": "dist/esm/index.js",
"types": "dist/cjs/index.d.ts",
"homepage": "https://github.com/fp-ts-quickcheck",
"version": "0.5.0",
"version": "0.6.0",
"files": [

@@ -16,2 +16,4 @@ "dist"

"@typescript-eslint/parser": "^5.14.0",
"commitizen": "^4.2.4",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.11.0",

@@ -24,5 +26,7 @@ "eslint-config-prettier": "^8.5.0",

"fast-check": "^2.17.0",
"husky": "^7.0.4",
"jest": "^27.2.2",
"jest-runner-eslint": "^1.0.0",
"npm-run-all": "^4.1.5",
"pnpm": "^6.32.8",
"prettier": "^2.5.1",

@@ -46,3 +50,5 @@ "standard-version": "^9.3.2",

"scripts": {
"build": "rm -rf dist && tsc -p tsconfig.es6.json & tsc -p tsconfig.cjs.json",
"build": "run-p build:*",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build:esm": "tsc -p tsconfig.esm.json",
"test": "jest",

@@ -49,0 +55,0 @@ "docs": "typedoc --out docs src/index.ts",

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