Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@morphism/utils

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@morphism/utils - npm Package Compare versions

Comparing version
0.1.6-alpha.6
to
0.1.6
+106
lib/Do.d.ts
export declare namespace Do {
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const addTen = ({ a }:{ a: number }) => Either.right(a + 10)
*
* const x = Do.forEither() // Initiates do notation syntax
* .let('a', 10) // Set 'a' to 10 in the context
* .bindL('b', addTen) // Lazily passes in 'a' to 'addTen' & binds result to context under 'b'
* .return(({ a }) => `${a} dollars`) // Returns a value derived from the context
*
* const y = pipe(
* x,
* Either.getOrElse(
* () => "No dollars"
* )
* )
*
* assert.deepStrictEqual(y, `20 dollars`)
*
* All `do` operations mimic the execute-on-success/ignore-on-failure behavior that functions
* like `Either.chain` and `Either.map` exhibit. This is where the benefits of do notation
* lie: it allows you to concisely describe a series of instructions by only concerning yourself
* with what should happen in the successful scenario. In the above example if any step of the
* process failed, `y` would end up being set to "No dollars".
*/
const forEither: () => import("fp-ts-contrib/lib/Do").Do2<"Either", {}>;
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const addTen = ({ a }:{ a: number }) => TaskEither.right(a + 10)
*
* const x = Do.forTaskEither() // Initiates do notation syntax
* .let('a', 10) // Eagerly set 'a' to 10 in the context
* .bindL('b', addTen) // Lazily passes in 'a' to 'addTen' & binds result to context under 'b'
* .return(({ a }) => `${a} dollars`) // Returns a value derived from the context
*
* const y = pipe(
* x,
* TaskEither.getOrElse(
* () => "No dollars"
* )
* )
*
* assert.deepStrictEqual(y, `20 dollars`)
*
* All operations on the `Do` instance mimic the execute-on-success/ignore-on-failure behavior that
* functions like `TaskEither.chain` and `TaskEither.map` exhibit. This is where the benefits of
* do notation lie: it allows you to concisely describe a series of instructions by only
* concerning yourself with what should happen in the happy path. In the above example if
* any step of the process failed, `y` would end up being set to "No dollars".
*/
const forTaskEither: () => import("fp-ts-contrib/lib/Do").Do2<"TaskEither", {}>;
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const x = Do.forTask() // Initiates do notation syntax
* .bind('a', Task.of(() => 'hello')) // Eagerly set 'a' to 'hello' in the context
* .bindL('b', () => Task.of(() => 'world')) // Lazily set 'b' to 'world'
* .return(({a, b}) => `${a} ${b}`) // Returns a value derived from the context
*
* const y = await x()
*
* assert.deepStrictEqual(y, `hello world`)
*/
const forTask: () => import("fp-ts-contrib/lib/Do").Do1<"Task", {}>;
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const x = Do.forOption() // Initiates do notation syntax
* .bind("a", Option.some(10)) // Eagerly set 'a' to 'hello' in the context
* .bind("b", Option.some(10)) // Eagerly set 'b' to 'world' in the context
* .bindL("c", ({ a, b }) => Option.some(a + b)) // Lazily derived 'c' from the current context
* .return(({c}) => c) // Return 'c'
*
* const y = pipe(
* x,
* Option.fold(
* () => 0
* )
* )
*
* assert.deepStrictEqual(y, 20)
*/
const forOption: () => import("fp-ts-contrib/lib/Do").Do1<"Option", {}>;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Do = void 0;
var fp_1 = require("@morphism/fp");
var Do_1 = require("fp-ts-contrib/lib/Do");
var fp_2 = require("@morphism/fp");
var Do;
(function (Do) {
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const addTen = ({ a }:{ a: number }) => Either.right(a + 10)
*
* const x = Do.forEither() // Initiates do notation syntax
* .let('a', 10) // Set 'a' to 10 in the context
* .bindL('b', addTen) // Lazily passes in 'a' to 'addTen' & binds result to context under 'b'
* .return(({ a }) => `${a} dollars`) // Returns a value derived from the context
*
* const y = pipe(
* x,
* Either.getOrElse(
* () => "No dollars"
* )
* )
*
* assert.deepStrictEqual(y, `20 dollars`)
*
* All `do` operations mimic the execute-on-success/ignore-on-failure behavior that functions
* like `Either.chain` and `Either.map` exhibit. This is where the benefits of do notation
* lie: it allows you to concisely describe a series of instructions by only concerning yourself
* with what should happen in the successful scenario. In the above example if any step of the
* process failed, `y` would end up being set to "No dollars".
*/
Do.forEither = function () { return Do_1.Do(fp_1.Either.either); };
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const addTen = ({ a }:{ a: number }) => TaskEither.right(a + 10)
*
* const x = Do.forTaskEither() // Initiates do notation syntax
* .let('a', 10) // Eagerly set 'a' to 10 in the context
* .bindL('b', addTen) // Lazily passes in 'a' to 'addTen' & binds result to context under 'b'
* .return(({ a }) => `${a} dollars`) // Returns a value derived from the context
*
* const y = pipe(
* x,
* TaskEither.getOrElse(
* () => "No dollars"
* )
* )
*
* assert.deepStrictEqual(y, `20 dollars`)
*
* All operations on the `Do` instance mimic the execute-on-success/ignore-on-failure behavior that
* functions like `TaskEither.chain` and `TaskEither.map` exhibit. This is where the benefits of
* do notation lie: it allows you to concisely describe a series of instructions by only
* concerning yourself with what should happen in the happy path. In the above example if
* any step of the process failed, `y` would end up being set to "No dollars".
*/
Do.forTaskEither = function () { return Do_1.Do(fp_1.TaskEither.taskEither); };
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const x = Do.forTask() // Initiates do notation syntax
* .bind('a', Task.of(() => 'hello')) // Eagerly set 'a' to 'hello' in the context
* .bindL('b', () => Task.of(() => 'world')) // Lazily set 'b' to 'world'
* .return(({a, b}) => `${a} ${b}`) // Returns a value derived from the context
*
* const y = await x()
*
* assert.deepStrictEqual(y, `hello world`)
*/
Do.forTask = function () { return Do_1.Do(fp_2.Task.task); };
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const x = Do.forOption() // Initiates do notation syntax
* .bind("a", Option.some(10)) // Eagerly set 'a' to 'hello' in the context
* .bind("b", Option.some(10)) // Eagerly set 'b' to 'world' in the context
* .bindL("c", ({ a, b }) => Option.some(a + b)) // Lazily derived 'c' from the current context
* .return(({c}) => c) // Return 'c'
*
* const y = pipe(
* x,
* Option.fold(
* () => 0
* )
* )
*
* assert.deepStrictEqual(y, 20)
*/
Do.forOption = function () { return Do_1.Do(fp_2.Option.option); };
})(Do = exports.Do || (exports.Do = {}));
//# sourceMappingURL=Do.js.map
{"version":3,"file":"Do.js","sourceRoot":"","sources":["../src/Do.ts"],"names":[],"mappings":";;;AAAA,mCAAkD;AAClD,2CAAwD;AACxD,mCAA4C;AAE5C,IAAiB,EAAE,CA4GlB;AA5GD,WAAiB,EAAE;IACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACU,YAAS,GAAG,cAAM,OAAA,OAAU,CAAC,WAAM,CAAC,MAAM,CAAC,EAAzB,CAAyB,CAAC;IAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACU,gBAAa,GAAG,cAAM,OAAA,OAAU,CAAC,eAAU,CAAC,UAAU,CAAC,EAAjC,CAAiC,CAAC;IAErE;;;;;;;;;;;;;;;;OAgBG;IACU,UAAO,GAAG,cAAM,OAAA,OAAU,CAAC,SAAI,CAAC,IAAI,CAAC,EAArB,CAAqB,CAAC;IAEnD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACU,YAAS,GAAG,cAAM,OAAA,OAAU,CAAC,WAAM,CAAC,MAAM,CAAC,EAAzB,CAAyB,CAAC;AAC3D,CAAC,EA5GgB,EAAE,GAAF,UAAE,KAAF,UAAE,QA4GlB"}
export declare const fromUnknown: (nonErrorPrefix?: string) => (unknown?: unknown) => Error;
"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 });
exports.fromUnknown = void 0;
var JSON = __importStar(require("./JSON"));
var fromUnknown = function (nonErrorPrefix) {
if (nonErrorPrefix === void 0) { nonErrorPrefix = "Unknown Error..."; }
return function (unknown) {
return !(unknown instanceof Error)
? new Error(nonErrorPrefix + "\n\n" + JSON.Stringify.Always.pretty(unknown))
: unknown;
};
};
exports.fromUnknown = fromUnknown;
//# sourceMappingURL=Exception.js.map
{"version":3,"file":"Exception.js","sourceRoot":"","sources":["../src/Exception.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA+B;AAExB,IAAM,WAAW,GAAG,UAAC,cAA2C;IAA3C,+BAAA,EAAA,mCAA2C;IAAK,OAAA,UAC1E,OAAiB;QAEjB,OAAA,CAAC,CAAC,OAAO,YAAY,KAAK,CAAC;YACzB,CAAC,CAAC,IAAI,KAAK,CAAI,cAAc,YAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAG,CAAC;YAC5E,CAAC,CAAC,OAAO;IAFX,CAEW;AAL+D,CAK/D,CAAC;AALD,QAAA,WAAW,eAKV"}
"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 });
var Exception = __importStar(require("./Exception"));
describe("Exception", function () {
it("handles unknown", function () {
var stringError = "some error";
var objectError = { value: "some error" };
var arrayError = ["some error"];
expect(Exception.fromUnknown()(stringError).message).toStrictEqual('Unknown Error...\n\n"some error"');
expect(Exception.fromUnknown()(objectError).message).toStrictEqual('Unknown Error...\n\n{\n "value": "some error"\n}');
expect(Exception.fromUnknown()(arrayError).message).toStrictEqual('Unknown Error...\n\n[\n "some error"\n]');
});
it("handles errors", function () {
var error = new Error("error string");
expect(Exception.fromUnknown()(error).message).toEqual("error string");
});
it("uses the 'prefix' argument when input is not an error", function () {
var stringError = "some error";
expect(Exception.fromUnknown("Some Prefix")(stringError).message).toEqual('Some Prefix\n\n"some error"');
});
});
//# sourceMappingURL=Exception.spec.js.map
{"version":3,"file":"Exception.spec.js","sourceRoot":"","sources":["../src/Exception.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,qDAAyC;AAEzC,QAAQ,CAAC,WAAW,EAAE;IACpB,EAAE,CAAC,iBAAiB,EAAE;QACpB,IAAM,WAAW,GAAG,YAAY,CAAC;QACjC,IAAM,WAAW,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;QAC5C,IAAM,UAAU,GAAG,CAAC,YAAY,CAAC,CAAC;QAElC,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,aAAa,CAChE,kCAAkC,CACnC,CAAC;QACF,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,aAAa,CAChE,mDAAmD,CACpD,CAAC;QACF,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,aAAa,CAC/D,0CAA0C,CAC3C,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gBAAgB,EAAE;QACnB,IAAM,KAAK,GAAG,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;QAExC,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE;QAC1D,IAAM,WAAW,GAAG,YAAY,CAAC;QAEjC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CACvE,6BAA6B,CAC9B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
export { ArrayOption } from "fp-ts-contrib/lib/ArrayOption";
import * as ArrayOption_ from "fp-ts-contrib/lib/ArrayOption";
declare module "./Generated" {
const ArrayOption: typeof ArrayOption_;
}
export { Free } from "fp-ts-contrib/lib/Free";
import * as Free_ from "fp-ts-contrib/lib/Free";
declare module "./Generated" {
const Free: typeof Free_;
}
export { IOOption } from "fp-ts-contrib/lib/IOOption";
import * as IOOption_ from "fp-ts-contrib/lib/IOOption";
declare module "./Generated" {
const IOOption: typeof IOOption_;
}
export { List } from "fp-ts-contrib/lib/List";
import * as List_ from "fp-ts-contrib/lib/List";
declare module "./Generated" {
const List: typeof List_;
}
export { ReaderIO } from "fp-ts-contrib/lib/ReaderIO";
import * as ReaderIO_ from "fp-ts-contrib/lib/ReaderIO";
declare module "./Generated" {
const ReaderIO: typeof ReaderIO_;
}
import * as RegExp_ from "fp-ts-contrib/lib/RegExp";
declare module "./Generated" {
const RegExp: typeof RegExp_;
}
export { StateEither } from "fp-ts-contrib/lib/StateEither";
import * as StateEither_ from "fp-ts-contrib/lib/StateEither";
declare module "./Generated" {
const StateEither: typeof StateEither_;
}
export { StateIO } from "fp-ts-contrib/lib/StateIO";
import * as StateIO_ from "fp-ts-contrib/lib/StateIO";
declare module "./Generated" {
const StateIO: typeof StateIO_;
}
export { StateTaskEither } from "fp-ts-contrib/lib/StateTaskEither";
import * as StateTaskEither_ from "fp-ts-contrib/lib/StateTaskEither";
declare module "./Generated" {
const StateTaskEither: typeof StateTaskEither_;
}
export { TaskOption } from "fp-ts-contrib/lib/TaskOption";
import * as TaskOption_ from "fp-ts-contrib/lib/TaskOption";
declare module "./Generated" {
const TaskOption: typeof TaskOption_;
}
export { Zipper } from "fp-ts-contrib/lib/Zipper";
import * as Zipper_ from "fp-ts-contrib/lib/Zipper";
declare module "./Generated" {
const Zipper: typeof Zipper_;
}
"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 });
var ArrayOption_ = __importStar(require("fp-ts-contrib/lib/ArrayOption"));
exports.ArrayOption = ArrayOption_;
var Free_ = __importStar(require("fp-ts-contrib/lib/Free"));
exports.Free = Free_;
var IOOption_ = __importStar(require("fp-ts-contrib/lib/IOOption"));
exports.IOOption = IOOption_;
var List_ = __importStar(require("fp-ts-contrib/lib/List"));
exports.List = List_;
var ReaderIO_ = __importStar(require("fp-ts-contrib/lib/ReaderIO"));
exports.ReaderIO = ReaderIO_;
var RegExp_ = __importStar(require("fp-ts-contrib/lib/RegExp"));
exports.RegExp = RegExp_;
var StateEither_ = __importStar(require("fp-ts-contrib/lib/StateEither"));
exports.StateEither = StateEither_;
var StateIO_ = __importStar(require("fp-ts-contrib/lib/StateIO"));
exports.StateIO = StateIO_;
var StateTaskEither_ = __importStar(require("fp-ts-contrib/lib/StateTaskEither"));
exports.StateTaskEither = StateTaskEither_;
var TaskOption_ = __importStar(require("fp-ts-contrib/lib/TaskOption"));
exports.TaskOption = TaskOption_;
var Zipper_ = __importStar(require("fp-ts-contrib/lib/Zipper"));
exports.Zipper = Zipper_;
//# sourceMappingURL=Generated.js.map
{"version":3,"file":"Generated.js","sourceRoot":"","sources":["../src/Generated.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,0EAA8D;AAC9D,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC;AAMnC,4DAAgD;AAChD,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC;AAMrB,oEAAwD;AACxD,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;AAM7B,4DAAgD;AAChD,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC;AAMrB,oEAAwD;AACxD,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;AAK7B,gEAAoD;AACpD,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC;AAMzB,0EAA8D;AAC9D,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC;AAMnC,kEAAsD;AACtD,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC;AAM3B,kFAAsE;AACtE,OAAO,CAAC,eAAe,GAAG,gBAAgB,CAAC;AAM3C,wEAA4D;AAC5D,OAAO,CAAC,UAAU,GAAG,WAAW,CAAC;AAMjC,gEAAoD;AACpD,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC"}
export * as JSON from "./JSON";
export { Do } from "./Do";
export * as Exception from "./Exception";
"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 });
exports.Exception = exports.Do = exports.JSON = void 0;
exports.JSON = __importStar(require("./JSON"));
var Do_1 = require("./Do");
Object.defineProperty(exports, "Do", { enumerable: true, get: function () { return Do_1.Do; } });
exports.Exception = __importStar(require("./Exception"));
//# sourceMappingURL=index.js.map
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA+B;AAC/B,2BAA0B;AAAjB,wFAAA,EAAE,OAAA;AACX,yDAAyC"}
import { Either } from "@morphism/fp";
export declare const parse: (string: string) => Either<Error, unknown>;
export declare namespace Stringify {
const short: (json: unknown) => Either<Error, string>;
const pretty: (json: unknown) => Either<Error, string>;
namespace Always {
const short: (json: unknown) => string;
const pretty: (json: unknown) => string;
}
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Stringify = exports.parse = void 0;
var fp_1 = require("@morphism/fp");
var parse = function (string) {
return fp_1.Either.parseJSON(string, onError);
};
exports.parse = parse;
var Stringify;
(function (Stringify) {
Stringify.short = function (json) {
return fp_1.Either.tryCatch(function () { return JSON.stringify(json); }, onError);
};
Stringify.pretty = function (json) {
return fp_1.Either.tryCatch(function () { return JSON.stringify(json, undefined, 2); }, onError);
};
var Always;
(function (Always) {
Always.short = function (json) {
return fp_1.pipe(Stringify.short(json), fp_1.Either.fold(defaultJSON, fp_1.Identity.of));
};
Always.pretty = function (json) {
return fp_1.pipe(Stringify.pretty(json), fp_1.Either.fold(defaultJSON, fp_1.Identity.of));
};
var defaultJSON = function () { return "{}"; };
})(Always = Stringify.Always || (Stringify.Always = {}));
})(Stringify = exports.Stringify || (exports.Stringify = {}));
var onError = function (error) {
return Error("Unrepresentable JSON value...\n\n" + error);
};
//# sourceMappingURL=JSON.js.map
{"version":3,"file":"JSON.js","sourceRoot":"","sources":["../src/JSON.ts"],"names":[],"mappings":";;;AAAA,mCAAsD;AAE/C,IAAM,KAAK,GAAG,UAAC,MAAc;IAClC,OAAA,WAAM,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC;AAAjC,CAAiC,CAAC;AADvB,QAAA,KAAK,SACkB;AAEpC,IAAiB,SAAS,CAgBzB;AAhBD,WAAiB,SAAS;IACX,eAAK,GAAG,UAAC,IAAa;QACjC,OAAA,WAAM,CAAC,QAAQ,CAAC,cAAM,OAAA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAApB,CAAoB,EAAE,OAAO,CAAC;IAApD,CAAoD,CAAC;IAE1C,gBAAM,GAAG,UAAC,IAAa;QAClC,OAAA,WAAM,CAAC,QAAQ,CAAC,cAAM,OAAA,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,EAAlC,CAAkC,EAAE,OAAO,CAAC;IAAlE,CAAkE,CAAC;IAErE,IAAiB,MAAM,CAQtB;IARD,WAAiB,MAAM;QACR,YAAK,GAAG,UAAC,IAAa;YACjC,OAAA,SAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,WAAM,CAAC,IAAI,CAAC,WAAW,EAAE,aAAQ,CAAC,EAAE,CAAC,CAAC;QAAlE,CAAkE,CAAC;QAExD,aAAM,GAAG,UAAC,IAAa;YAClC,OAAA,SAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,WAAM,CAAC,IAAI,CAAC,WAAW,EAAE,aAAQ,CAAC,EAAE,CAAC,CAAC;QAAnE,CAAmE,CAAC;QAEtE,IAAM,WAAW,GAAG,cAAc,OAAA,IAAI,EAAJ,CAAI,CAAC;IACzC,CAAC,EARgB,MAAM,GAAN,gBAAM,KAAN,gBAAM,QAQtB;AACH,CAAC,EAhBgB,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAgBzB;AAED,IAAM,OAAO,GAAG,UAAC,KAAc;IAC7B,OAAA,KAAK,CAAC,sCAAoC,KAAO,CAAC;AAAlD,CAAkD,CAAC"}
+9
-15

@@ -5,4 +5,4 @@ {

"license": "MIT",
"version": "0.1.6-alpha.6+5184032",
"gitHead": "518403208515c51019e64ea510ca73d9bd292bf3",
"version": "0.1.6",
"gitHead": "417849ba7c2da14e2803401226a09a32ab259219",
"repository": {

@@ -12,9 +12,4 @@ "type": "git",

},
"main": "lib/cjs/index.js",
"module": "lib/esm/index.js",
"types": "lib/esm/index.d.ts",
"exports": {
"require": "./lib/cjs/index.js",
"import": "./lib/esm/index.js"
},
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [

@@ -29,9 +24,9 @@ "lib",

"generate": "ts-node scripts/Generate.ts",
"postgenerate": "prettier --write src/Generated.ts",
"prebuild": "rimraf lib && yarn generate",
"build": "tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json",
"postgenerate": "prettier --write ./src/Generated.ts",
"prebuild": "rm -rf ./lib",
"build": "yarn generate && tsc --project tsconfig.lib.json",
"prepublishOnly": "yarn build"
},
"peerDependencies": {
"@morphism/fp": "^0.3.1",
"@morphism/fp": "^0.3.7",
"fp-ts": "^2.9.5",

@@ -41,3 +36,3 @@ "fp-ts-contrib": "^0.1.21"

"devDependencies": {
"@morphism/fp": "^0.3.8-alpha.6+5184032",
"@morphism/fp": "^0.3.8",
"@types/jest": "^26.0.20",

@@ -54,3 +49,2 @@ "@types/node": "^14.14.11",

"prettier": "^2.2.1",
"rimraf": "^3.0.2",
"ts-jest": "^26.5.3",

@@ -57,0 +51,0 @@ "ts-node": "^9.1.1",

export declare namespace Do {
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const addTen = ({ a }:{ a: number }) => Either.right(a + 10)
*
* const x = Do.forEither() // Initiates do notation syntax
* .let('a', 10) // Set 'a' to 10 in the context
* .bindL('b', addTen) // Lazily passes in 'a' to 'addTen' & binds result to context under 'b'
* .return(({ a }) => `${a} dollars`) // Returns a value derived from the context
*
* const y = pipe(
* x,
* Either.getOrElse(
* () => "No dollars"
* )
* )
*
* assert.deepStrictEqual(y, `20 dollars`)
*
* All `do` operations mimic the execute-on-success/ignore-on-failure behavior that functions
* like `Either.chain` and `Either.map` exhibit. This is where the benefits of do notation
* lie: it allows you to concisely describe a series of instructions by only concerning yourself
* with what should happen in the successful scenario. In the above example if any step of the
* process failed, `y` would end up being set to "No dollars".
*/
const forEither: () => import("fp-ts-contrib/lib/Do").Do2<"Either", {}>;
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const addTen = ({ a }:{ a: number }) => TaskEither.right(a + 10)
*
* const x = Do.forTaskEither() // Initiates do notation syntax
* .let('a', 10) // Eagerly set 'a' to 10 in the context
* .bindL('b', addTen) // Lazily passes in 'a' to 'addTen' & binds result to context under 'b'
* .return(({ a }) => `${a} dollars`) // Returns a value derived from the context
*
* const y = pipe(
* x,
* TaskEither.getOrElse(
* () => "No dollars"
* )
* )
*
* assert.deepStrictEqual(y, `20 dollars`)
*
* All operations on the `Do` instance mimic the execute-on-success/ignore-on-failure behavior that
* functions like `TaskEither.chain` and `TaskEither.map` exhibit. This is where the benefits of
* do notation lie: it allows you to concisely describe a series of instructions by only
* concerning yourself with what should happen in the happy path. In the above example if
* any step of the process failed, `y` would end up being set to "No dollars".
*/
const forTaskEither: () => import("fp-ts-contrib/lib/Do").Do2<"TaskEither", {}>;
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const x = Do.forTask() // Initiates do notation syntax
* .bind('a', Task.of(() => 'hello')) // Eagerly set 'a' to 'hello' in the context
* .bindL('b', () => Task.of(() => 'world')) // Lazily set 'b' to 'world'
* .return(({a, b}) => `${a} ${b}`) // Returns a value derived from the context
*
* const y = await x()
*
* assert.deepStrictEqual(y, `hello world`)
*/
const forTask: () => import("fp-ts-contrib/lib/Do").Do1<"Task", {}>;
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const x = Do.forOption() // Initiates do notation syntax
* .bind("a", Option.some(10)) // Eagerly set 'a' to 'hello' in the context
* .bind("b", Option.some(10)) // Eagerly set 'b' to 'world' in the context
* .bindL("c", ({ a, b }) => Option.some(a + b)) // Lazily derived 'c' from the current context
* .return(({c}) => c) // Return 'c'
*
* const y = pipe(
* x,
* Option.fold(
* () => 0
* )
* )
*
* assert.deepStrictEqual(y, 20)
*/
const forOption: () => import("fp-ts-contrib/lib/Do").Do1<"Option", {}>;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Do = void 0;
var fp_1 = require("@morphism/fp");
var Do_1 = require("fp-ts-contrib/lib/Do");
var fp_2 = require("@morphism/fp");
var Do;
(function (Do) {
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const addTen = ({ a }:{ a: number }) => Either.right(a + 10)
*
* const x = Do.forEither() // Initiates do notation syntax
* .let('a', 10) // Set 'a' to 10 in the context
* .bindL('b', addTen) // Lazily passes in 'a' to 'addTen' & binds result to context under 'b'
* .return(({ a }) => `${a} dollars`) // Returns a value derived from the context
*
* const y = pipe(
* x,
* Either.getOrElse(
* () => "No dollars"
* )
* )
*
* assert.deepStrictEqual(y, `20 dollars`)
*
* All `do` operations mimic the execute-on-success/ignore-on-failure behavior that functions
* like `Either.chain` and `Either.map` exhibit. This is where the benefits of do notation
* lie: it allows you to concisely describe a series of instructions by only concerning yourself
* with what should happen in the successful scenario. In the above example if any step of the
* process failed, `y` would end up being set to "No dollars".
*/
Do.forEither = function () { return Do_1.Do(fp_1.Either.either); };
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const addTen = ({ a }:{ a: number }) => TaskEither.right(a + 10)
*
* const x = Do.forTaskEither() // Initiates do notation syntax
* .let('a', 10) // Eagerly set 'a' to 10 in the context
* .bindL('b', addTen) // Lazily passes in 'a' to 'addTen' & binds result to context under 'b'
* .return(({ a }) => `${a} dollars`) // Returns a value derived from the context
*
* const y = pipe(
* x,
* TaskEither.getOrElse(
* () => "No dollars"
* )
* )
*
* assert.deepStrictEqual(y, `20 dollars`)
*
* All operations on the `Do` instance mimic the execute-on-success/ignore-on-failure behavior that
* functions like `TaskEither.chain` and `TaskEither.map` exhibit. This is where the benefits of
* do notation lie: it allows you to concisely describe a series of instructions by only
* concerning yourself with what should happen in the happy path. In the above example if
* any step of the process failed, `y` would end up being set to "No dollars".
*/
Do.forTaskEither = function () { return Do_1.Do(fp_1.TaskEither.taskEither); };
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const x = Do.forTask() // Initiates do notation syntax
* .bind('a', Task.of(() => 'hello')) // Eagerly set 'a' to 'hello' in the context
* .bindL('b', () => Task.of(() => 'world')) // Lazily set 'b' to 'world'
* .return(({a, b}) => `${a} ${b}`) // Returns a value derived from the context
*
* const y = await x()
*
* assert.deepStrictEqual(y, `hello world`)
*/
Do.forTask = function () { return Do_1.Do(fp_2.Task.task); };
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const x = Do.forOption() // Initiates do notation syntax
* .bind("a", Option.some(10)) // Eagerly set 'a' to 'hello' in the context
* .bind("b", Option.some(10)) // Eagerly set 'b' to 'world' in the context
* .bindL("c", ({ a, b }) => Option.some(a + b)) // Lazily derived 'c' from the current context
* .return(({c}) => c) // Return 'c'
*
* const y = pipe(
* x,
* Option.fold(
* () => 0
* )
* )
*
* assert.deepStrictEqual(y, 20)
*/
Do.forOption = function () { return Do_1.Do(fp_2.Option.option); };
})(Do = exports.Do || (exports.Do = {}));
//# sourceMappingURL=Do.js.map
{"version":3,"file":"Do.js","sourceRoot":"","sources":["../../src/Do.ts"],"names":[],"mappings":";;;AAAA,mCAAkD;AAClD,2CAAwD;AACxD,mCAA4C;AAE5C,IAAiB,EAAE,CA4GlB;AA5GD,WAAiB,EAAE;IACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACU,YAAS,GAAG,cAAM,OAAA,OAAU,CAAC,WAAM,CAAC,MAAM,CAAC,EAAzB,CAAyB,CAAC;IAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACU,gBAAa,GAAG,cAAM,OAAA,OAAU,CAAC,eAAU,CAAC,UAAU,CAAC,EAAjC,CAAiC,CAAC;IAErE;;;;;;;;;;;;;;;;OAgBG;IACU,UAAO,GAAG,cAAM,OAAA,OAAU,CAAC,SAAI,CAAC,IAAI,CAAC,EAArB,CAAqB,CAAC;IAEnD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACU,YAAS,GAAG,cAAM,OAAA,OAAU,CAAC,WAAM,CAAC,MAAM,CAAC,EAAzB,CAAyB,CAAC;AAC3D,CAAC,EA5GgB,EAAE,GAAF,UAAE,KAAF,UAAE,QA4GlB"}
export declare const fromUnknown: (nonErrorPrefix?: string) => (unknown?: unknown) => Error;
"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 });
exports.fromUnknown = void 0;
var JSON = __importStar(require("./JSON"));
var fromUnknown = function (nonErrorPrefix) {
if (nonErrorPrefix === void 0) { nonErrorPrefix = "Unknown Error..."; }
return function (unknown) {
return !(unknown instanceof Error)
? new Error(nonErrorPrefix + "\n\n" + JSON.Stringify.Always.pretty(unknown))
: unknown;
};
};
exports.fromUnknown = fromUnknown;
//# sourceMappingURL=Exception.js.map
{"version":3,"file":"Exception.js","sourceRoot":"","sources":["../../src/Exception.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA+B;AAExB,IAAM,WAAW,GAAG,UAAC,cAA2C;IAA3C,+BAAA,EAAA,mCAA2C;IAAK,OAAA,UAC1E,OAAiB;QAEjB,OAAA,CAAC,CAAC,OAAO,YAAY,KAAK,CAAC;YACzB,CAAC,CAAC,IAAI,KAAK,CAAI,cAAc,YAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAG,CAAC;YAC5E,CAAC,CAAC,OAAO;IAFX,CAEW;AAL+D,CAK/D,CAAC;AALD,QAAA,WAAW,eAKV"}
"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 });
var Exception = __importStar(require("./Exception"));
describe("Exception", function () {
it("handles unknown", function () {
var stringError = "some error";
var objectError = { value: "some error" };
var arrayError = ["some error"];
expect(Exception.fromUnknown()(stringError).message).toStrictEqual('Unknown Error...\n\n"some error"');
expect(Exception.fromUnknown()(objectError).message).toStrictEqual('Unknown Error...\n\n{\n "value": "some error"\n}');
expect(Exception.fromUnknown()(arrayError).message).toStrictEqual('Unknown Error...\n\n[\n "some error"\n]');
});
it("handles errors", function () {
var error = new Error("error string");
expect(Exception.fromUnknown()(error).message).toEqual("error string");
});
it("uses the 'prefix' argument when input is not an error", function () {
var stringError = "some error";
expect(Exception.fromUnknown("Some Prefix")(stringError).message).toEqual('Some Prefix\n\n"some error"');
});
});
//# sourceMappingURL=Exception.spec.js.map
{"version":3,"file":"Exception.spec.js","sourceRoot":"","sources":["../../src/Exception.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,qDAAyC;AAEzC,QAAQ,CAAC,WAAW,EAAE;IACpB,EAAE,CAAC,iBAAiB,EAAE;QACpB,IAAM,WAAW,GAAG,YAAY,CAAC;QACjC,IAAM,WAAW,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;QAC5C,IAAM,UAAU,GAAG,CAAC,YAAY,CAAC,CAAC;QAElC,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,aAAa,CAChE,kCAAkC,CACnC,CAAC;QACF,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,aAAa,CAChE,mDAAmD,CACpD,CAAC;QACF,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,aAAa,CAC/D,0CAA0C,CAC3C,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gBAAgB,EAAE;QACnB,IAAM,KAAK,GAAG,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;QAExC,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE;QAC1D,IAAM,WAAW,GAAG,YAAY,CAAC;QAEjC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CACvE,6BAA6B,CAC9B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
export { ArrayOption } from "fp-ts-contrib/lib/ArrayOption";
import * as ArrayOption_ from "fp-ts-contrib/lib/ArrayOption";
declare module "./Generated" {
const ArrayOption: typeof ArrayOption_;
}
export { Free } from "fp-ts-contrib/lib/Free";
import * as Free_ from "fp-ts-contrib/lib/Free";
declare module "./Generated" {
const Free: typeof Free_;
}
export { IOOption } from "fp-ts-contrib/lib/IOOption";
import * as IOOption_ from "fp-ts-contrib/lib/IOOption";
declare module "./Generated" {
const IOOption: typeof IOOption_;
}
export { List } from "fp-ts-contrib/lib/List";
import * as List_ from "fp-ts-contrib/lib/List";
declare module "./Generated" {
const List: typeof List_;
}
export { ReaderIO } from "fp-ts-contrib/lib/ReaderIO";
import * as ReaderIO_ from "fp-ts-contrib/lib/ReaderIO";
declare module "./Generated" {
const ReaderIO: typeof ReaderIO_;
}
import * as RegExp_ from "fp-ts-contrib/lib/RegExp";
declare module "./Generated" {
const RegExp: typeof RegExp_;
}
export { StateEither } from "fp-ts-contrib/lib/StateEither";
import * as StateEither_ from "fp-ts-contrib/lib/StateEither";
declare module "./Generated" {
const StateEither: typeof StateEither_;
}
export { StateIO } from "fp-ts-contrib/lib/StateIO";
import * as StateIO_ from "fp-ts-contrib/lib/StateIO";
declare module "./Generated" {
const StateIO: typeof StateIO_;
}
export { StateTaskEither } from "fp-ts-contrib/lib/StateTaskEither";
import * as StateTaskEither_ from "fp-ts-contrib/lib/StateTaskEither";
declare module "./Generated" {
const StateTaskEither: typeof StateTaskEither_;
}
export { TaskOption } from "fp-ts-contrib/lib/TaskOption";
import * as TaskOption_ from "fp-ts-contrib/lib/TaskOption";
declare module "./Generated" {
const TaskOption: typeof TaskOption_;
}
export { Zipper } from "fp-ts-contrib/lib/Zipper";
import * as Zipper_ from "fp-ts-contrib/lib/Zipper";
declare module "./Generated" {
const Zipper: typeof Zipper_;
}
"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 });
var ArrayOption_ = __importStar(require("fp-ts-contrib/lib/ArrayOption"));
exports.ArrayOption = ArrayOption_;
var Free_ = __importStar(require("fp-ts-contrib/lib/Free"));
exports.Free = Free_;
var IOOption_ = __importStar(require("fp-ts-contrib/lib/IOOption"));
exports.IOOption = IOOption_;
var List_ = __importStar(require("fp-ts-contrib/lib/List"));
exports.List = List_;
var ReaderIO_ = __importStar(require("fp-ts-contrib/lib/ReaderIO"));
exports.ReaderIO = ReaderIO_;
var RegExp_ = __importStar(require("fp-ts-contrib/lib/RegExp"));
exports.RegExp = RegExp_;
var StateEither_ = __importStar(require("fp-ts-contrib/lib/StateEither"));
exports.StateEither = StateEither_;
var StateIO_ = __importStar(require("fp-ts-contrib/lib/StateIO"));
exports.StateIO = StateIO_;
var StateTaskEither_ = __importStar(require("fp-ts-contrib/lib/StateTaskEither"));
exports.StateTaskEither = StateTaskEither_;
var TaskOption_ = __importStar(require("fp-ts-contrib/lib/TaskOption"));
exports.TaskOption = TaskOption_;
var Zipper_ = __importStar(require("fp-ts-contrib/lib/Zipper"));
exports.Zipper = Zipper_;
//# sourceMappingURL=Generated.js.map
{"version":3,"file":"Generated.js","sourceRoot":"","sources":["../../src/Generated.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,0EAA8D;AAC9D,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC;AAMnC,4DAAgD;AAChD,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC;AAMrB,oEAAwD;AACxD,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;AAM7B,4DAAgD;AAChD,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC;AAMrB,oEAAwD;AACxD,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;AAK7B,gEAAoD;AACpD,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC;AAMzB,0EAA8D;AAC9D,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC;AAMnC,kEAAsD;AACtD,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC;AAM3B,kFAAsE;AACtE,OAAO,CAAC,eAAe,GAAG,gBAAgB,CAAC;AAM3C,wEAA4D;AAC5D,OAAO,CAAC,UAAU,GAAG,WAAW,CAAC;AAMjC,gEAAoD;AACpD,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC"}
export * from "./Generated";
export * as JSON from "./JSON";
export { Do } from "./Do";
export * as Exception from "./Exception";
"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 __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
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 });
exports.Exception = exports.Do = exports.JSON = void 0;
__exportStar(require("./Generated"), exports);
exports.JSON = __importStar(require("./JSON"));
var Do_1 = require("./Do");
Object.defineProperty(exports, "Do", { enumerable: true, get: function () { return Do_1.Do; } });
exports.Exception = __importStar(require("./Exception"));
//# sourceMappingURL=index.js.map
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,+CAA+B;AAC/B,2BAA0B;AAAjB,wFAAA,EAAE,OAAA;AACX,yDAAyC"}
import { Either } from "@morphism/fp";
export declare const parse: (string: string) => Either<Error, unknown>;
export declare namespace Stringify {
const short: (json: unknown) => Either<Error, string>;
const pretty: (json: unknown) => Either<Error, string>;
namespace Always {
const short: (json: unknown) => string;
const pretty: (json: unknown) => string;
}
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Stringify = exports.parse = void 0;
var fp_1 = require("@morphism/fp");
var parse = function (string) {
return fp_1.Either.parseJSON(string, onError);
};
exports.parse = parse;
var Stringify;
(function (Stringify) {
Stringify.short = function (json) {
return fp_1.Either.tryCatch(function () { return JSON.stringify(json); }, onError);
};
Stringify.pretty = function (json) {
return fp_1.Either.tryCatch(function () { return JSON.stringify(json, undefined, 2); }, onError);
};
var Always;
(function (Always) {
Always.short = function (json) {
return fp_1.pipe(Stringify.short(json), fp_1.Either.fold(defaultJSON, fp_1.Identity.of));
};
Always.pretty = function (json) {
return fp_1.pipe(Stringify.pretty(json), fp_1.Either.fold(defaultJSON, fp_1.Identity.of));
};
var defaultJSON = function () { return "{}"; };
})(Always = Stringify.Always || (Stringify.Always = {}));
})(Stringify = exports.Stringify || (exports.Stringify = {}));
var onError = function (error) {
return Error("Unrepresentable JSON value...\n\n" + error);
};
//# sourceMappingURL=JSON.js.map
{"version":3,"file":"JSON.js","sourceRoot":"","sources":["../../src/JSON.ts"],"names":[],"mappings":";;;AAAA,mCAAsD;AAE/C,IAAM,KAAK,GAAG,UAAC,MAAc;IAClC,OAAA,WAAM,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC;AAAjC,CAAiC,CAAC;AADvB,QAAA,KAAK,SACkB;AAEpC,IAAiB,SAAS,CAgBzB;AAhBD,WAAiB,SAAS;IACX,eAAK,GAAG,UAAC,IAAa;QACjC,OAAA,WAAM,CAAC,QAAQ,CAAC,cAAM,OAAA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAApB,CAAoB,EAAE,OAAO,CAAC;IAApD,CAAoD,CAAC;IAE1C,gBAAM,GAAG,UAAC,IAAa;QAClC,OAAA,WAAM,CAAC,QAAQ,CAAC,cAAM,OAAA,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,EAAlC,CAAkC,EAAE,OAAO,CAAC;IAAlE,CAAkE,CAAC;IAErE,IAAiB,MAAM,CAQtB;IARD,WAAiB,MAAM;QACR,YAAK,GAAG,UAAC,IAAa;YACjC,OAAA,SAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,WAAM,CAAC,IAAI,CAAC,WAAW,EAAE,aAAQ,CAAC,EAAE,CAAC,CAAC;QAAlE,CAAkE,CAAC;QAExD,aAAM,GAAG,UAAC,IAAa;YAClC,OAAA,SAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,WAAM,CAAC,IAAI,CAAC,WAAW,EAAE,aAAQ,CAAC,EAAE,CAAC,CAAC;QAAnE,CAAmE,CAAC;QAEtE,IAAM,WAAW,GAAG,cAAc,OAAA,IAAI,EAAJ,CAAI,CAAC;IACzC,CAAC,EARgB,MAAM,GAAN,gBAAM,KAAN,gBAAM,QAQtB;AACH,CAAC,EAhBgB,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAgBzB;AAED,IAAM,OAAO,GAAG,UAAC,KAAc;IAC7B,OAAA,KAAK,CAAC,sCAAoC,KAAO,CAAC;AAAlD,CAAkD,CAAC"}
export declare namespace Do {
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const addTen = ({ a }:{ a: number }) => Either.right(a + 10)
*
* const x = Do.forEither() // Initiates do notation syntax
* .let('a', 10) // Set 'a' to 10 in the context
* .bindL('b', addTen) // Lazily passes in 'a' to 'addTen' & binds result to context under 'b'
* .return(({ a }) => `${a} dollars`) // Returns a value derived from the context
*
* const y = pipe(
* x,
* Either.getOrElse(
* () => "No dollars"
* )
* )
*
* assert.deepStrictEqual(y, `20 dollars`)
*
* All `do` operations mimic the execute-on-success/ignore-on-failure behavior that functions
* like `Either.chain` and `Either.map` exhibit. This is where the benefits of do notation
* lie: it allows you to concisely describe a series of instructions by only concerning yourself
* with what should happen in the successful scenario. In the above example if any step of the
* process failed, `y` would end up being set to "No dollars".
*/
const forEither: () => import("fp-ts-contrib/lib/Do").Do2<"Either", {}>;
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const addTen = ({ a }:{ a: number }) => TaskEither.right(a + 10)
*
* const x = Do.forTaskEither() // Initiates do notation syntax
* .let('a', 10) // Eagerly set 'a' to 10 in the context
* .bindL('b', addTen) // Lazily passes in 'a' to 'addTen' & binds result to context under 'b'
* .return(({ a }) => `${a} dollars`) // Returns a value derived from the context
*
* const y = pipe(
* x,
* TaskEither.getOrElse(
* () => "No dollars"
* )
* )
*
* assert.deepStrictEqual(y, `20 dollars`)
*
* All operations on the `Do` instance mimic the execute-on-success/ignore-on-failure behavior that
* functions like `TaskEither.chain` and `TaskEither.map` exhibit. This is where the benefits of
* do notation lie: it allows you to concisely describe a series of instructions by only
* concerning yourself with what should happen in the happy path. In the above example if
* any step of the process failed, `y` would end up being set to "No dollars".
*/
const forTaskEither: () => import("fp-ts-contrib/lib/Do").Do2<"TaskEither", {}>;
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const x = Do.forTask() // Initiates do notation syntax
* .bind('a', Task.of(() => 'hello')) // Eagerly set 'a' to 'hello' in the context
* .bindL('b', () => Task.of(() => 'world')) // Lazily set 'b' to 'world'
* .return(({a, b}) => `${a} ${b}`) // Returns a value derived from the context
*
* const y = await x()
*
* assert.deepStrictEqual(y, `hello world`)
*/
const forTask: () => import("fp-ts-contrib/lib/Do").Do1<"Task", {}>;
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const x = Do.forOption() // Initiates do notation syntax
* .bind("a", Option.some(10)) // Eagerly set 'a' to 'hello' in the context
* .bind("b", Option.some(10)) // Eagerly set 'b' to 'world' in the context
* .bindL("c", ({ a, b }) => Option.some(a + b)) // Lazily derived 'c' from the current context
* .return(({c}) => c) // Return 'c'
*
* const y = pipe(
* x,
* Option.fold(
* () => 0
* )
* )
*
* assert.deepStrictEqual(y, 20)
*/
const forOption: () => import("fp-ts-contrib/lib/Do").Do1<"Option", {}>;
}
import { Either, TaskEither } from "@morphism/fp";
import { Do as DoNotation } from "fp-ts-contrib/lib/Do";
import { Option, Task } from "@morphism/fp";
export var Do;
(function (Do) {
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const addTen = ({ a }:{ a: number }) => Either.right(a + 10)
*
* const x = Do.forEither() // Initiates do notation syntax
* .let('a', 10) // Set 'a' to 10 in the context
* .bindL('b', addTen) // Lazily passes in 'a' to 'addTen' & binds result to context under 'b'
* .return(({ a }) => `${a} dollars`) // Returns a value derived from the context
*
* const y = pipe(
* x,
* Either.getOrElse(
* () => "No dollars"
* )
* )
*
* assert.deepStrictEqual(y, `20 dollars`)
*
* All `do` operations mimic the execute-on-success/ignore-on-failure behavior that functions
* like `Either.chain` and `Either.map` exhibit. This is where the benefits of do notation
* lie: it allows you to concisely describe a series of instructions by only concerning yourself
* with what should happen in the successful scenario. In the above example if any step of the
* process failed, `y` would end up being set to "No dollars".
*/
Do.forEither = function () { return DoNotation(Either.either); };
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const addTen = ({ a }:{ a: number }) => TaskEither.right(a + 10)
*
* const x = Do.forTaskEither() // Initiates do notation syntax
* .let('a', 10) // Eagerly set 'a' to 10 in the context
* .bindL('b', addTen) // Lazily passes in 'a' to 'addTen' & binds result to context under 'b'
* .return(({ a }) => `${a} dollars`) // Returns a value derived from the context
*
* const y = pipe(
* x,
* TaskEither.getOrElse(
* () => "No dollars"
* )
* )
*
* assert.deepStrictEqual(y, `20 dollars`)
*
* All operations on the `Do` instance mimic the execute-on-success/ignore-on-failure behavior that
* functions like `TaskEither.chain` and `TaskEither.map` exhibit. This is where the benefits of
* do notation lie: it allows you to concisely describe a series of instructions by only
* concerning yourself with what should happen in the happy path. In the above example if
* any step of the process failed, `y` would end up being set to "No dollars".
*/
Do.forTaskEither = function () { return DoNotation(TaskEither.taskEither); };
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const x = Do.forTask() // Initiates do notation syntax
* .bind('a', Task.of(() => 'hello')) // Eagerly set 'a' to 'hello' in the context
* .bindL('b', () => Task.of(() => 'world')) // Lazily set 'b' to 'world'
* .return(({a, b}) => `${a} ${b}`) // Returns a value derived from the context
*
* const y = await x()
*
* assert.deepStrictEqual(y, `hello world`)
*/
Do.forTask = function () { return DoNotation(Task.task); };
/**
* This function provides a simulation of Haskell do notation. The `bind` / `bindL` functions
* contribute to a threaded scope that is available to each subsequent step. The `do` / `doL`
* functions can be used to perform computations that add nothing to the scope. The `done`
* function returns the threaded scope that was built, while the `return` function provides
* that threaded scope so that a custom value derived from the threaded scope can be returned.
*
* @example
* const x = Do.forOption() // Initiates do notation syntax
* .bind("a", Option.some(10)) // Eagerly set 'a' to 'hello' in the context
* .bind("b", Option.some(10)) // Eagerly set 'b' to 'world' in the context
* .bindL("c", ({ a, b }) => Option.some(a + b)) // Lazily derived 'c' from the current context
* .return(({c}) => c) // Return 'c'
*
* const y = pipe(
* x,
* Option.fold(
* () => 0
* )
* )
*
* assert.deepStrictEqual(y, 20)
*/
Do.forOption = function () { return DoNotation(Option.option); };
})(Do || (Do = {}));
//# sourceMappingURL=Do.js.map
{"version":3,"file":"Do.js","sourceRoot":"","sources":["../../src/Do.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,EAAE,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,KAAW,EAAE,CA4GlB;AA5GD,WAAiB,EAAE;IACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACU,YAAS,GAAG,cAAM,OAAA,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,EAAzB,CAAyB,CAAC;IAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACU,gBAAa,GAAG,cAAM,OAAA,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,EAAjC,CAAiC,CAAC;IAErE;;;;;;;;;;;;;;;;OAgBG;IACU,UAAO,GAAG,cAAM,OAAA,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAArB,CAAqB,CAAC;IAEnD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACU,YAAS,GAAG,cAAM,OAAA,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,EAAzB,CAAyB,CAAC;AAC3D,CAAC,EA5GgB,EAAE,KAAF,EAAE,QA4GlB"}
export declare const fromUnknown: (nonErrorPrefix?: string) => (unknown?: unknown) => Error;
import * as JSON from "./JSON";
export var fromUnknown = function (nonErrorPrefix) {
if (nonErrorPrefix === void 0) { nonErrorPrefix = "Unknown Error..."; }
return function (unknown) {
return !(unknown instanceof Error)
? new Error(nonErrorPrefix + "\n\n" + JSON.Stringify.Always.pretty(unknown))
: unknown;
};
};
//# sourceMappingURL=Exception.js.map
{"version":3,"file":"Exception.js","sourceRoot":"","sources":["../../src/Exception.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAE/B,MAAM,CAAC,IAAM,WAAW,GAAG,UAAC,cAA2C;IAA3C,+BAAA,EAAA,mCAA2C;IAAK,OAAA,UAC1E,OAAiB;QAEjB,OAAA,CAAC,CAAC,OAAO,YAAY,KAAK,CAAC;YACzB,CAAC,CAAC,IAAI,KAAK,CAAI,cAAc,YAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAG,CAAC;YAC5E,CAAC,CAAC,OAAO;IAFX,CAEW;AAL+D,CAK/D,CAAC"}
import * as Exception from "./Exception";
describe("Exception", function () {
it("handles unknown", function () {
var stringError = "some error";
var objectError = { value: "some error" };
var arrayError = ["some error"];
expect(Exception.fromUnknown()(stringError).message).toStrictEqual('Unknown Error...\n\n"some error"');
expect(Exception.fromUnknown()(objectError).message).toStrictEqual('Unknown Error...\n\n{\n "value": "some error"\n}');
expect(Exception.fromUnknown()(arrayError).message).toStrictEqual('Unknown Error...\n\n[\n "some error"\n]');
});
it("handles errors", function () {
var error = new Error("error string");
expect(Exception.fromUnknown()(error).message).toEqual("error string");
});
it("uses the 'prefix' argument when input is not an error", function () {
var stringError = "some error";
expect(Exception.fromUnknown("Some Prefix")(stringError).message).toEqual('Some Prefix\n\n"some error"');
});
});
//# sourceMappingURL=Exception.spec.js.map
{"version":3,"file":"Exception.spec.js","sourceRoot":"","sources":["../../src/Exception.spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,QAAQ,CAAC,WAAW,EAAE;IACpB,EAAE,CAAC,iBAAiB,EAAE;QACpB,IAAM,WAAW,GAAG,YAAY,CAAC;QACjC,IAAM,WAAW,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;QAC5C,IAAM,UAAU,GAAG,CAAC,YAAY,CAAC,CAAC;QAElC,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,aAAa,CAChE,kCAAkC,CACnC,CAAC;QACF,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,aAAa,CAChE,mDAAmD,CACpD,CAAC;QACF,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,aAAa,CAC/D,0CAA0C,CAC3C,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gBAAgB,EAAE;QACnB,IAAM,KAAK,GAAG,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;QAExC,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE;QAC1D,IAAM,WAAW,GAAG,YAAY,CAAC;QAEjC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CACvE,6BAA6B,CAC9B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
export { ArrayOption } from "fp-ts-contrib/lib/ArrayOption";
import * as ArrayOption_ from "fp-ts-contrib/lib/ArrayOption";
declare module "./Generated" {
const ArrayOption: typeof ArrayOption_;
}
export { Free } from "fp-ts-contrib/lib/Free";
import * as Free_ from "fp-ts-contrib/lib/Free";
declare module "./Generated" {
const Free: typeof Free_;
}
export { IOOption } from "fp-ts-contrib/lib/IOOption";
import * as IOOption_ from "fp-ts-contrib/lib/IOOption";
declare module "./Generated" {
const IOOption: typeof IOOption_;
}
export { List } from "fp-ts-contrib/lib/List";
import * as List_ from "fp-ts-contrib/lib/List";
declare module "./Generated" {
const List: typeof List_;
}
export { ReaderIO } from "fp-ts-contrib/lib/ReaderIO";
import * as ReaderIO_ from "fp-ts-contrib/lib/ReaderIO";
declare module "./Generated" {
const ReaderIO: typeof ReaderIO_;
}
import * as RegExp_ from "fp-ts-contrib/lib/RegExp";
declare module "./Generated" {
const RegExp: typeof RegExp_;
}
export { StateEither } from "fp-ts-contrib/lib/StateEither";
import * as StateEither_ from "fp-ts-contrib/lib/StateEither";
declare module "./Generated" {
const StateEither: typeof StateEither_;
}
export { StateIO } from "fp-ts-contrib/lib/StateIO";
import * as StateIO_ from "fp-ts-contrib/lib/StateIO";
declare module "./Generated" {
const StateIO: typeof StateIO_;
}
export { StateTaskEither } from "fp-ts-contrib/lib/StateTaskEither";
import * as StateTaskEither_ from "fp-ts-contrib/lib/StateTaskEither";
declare module "./Generated" {
const StateTaskEither: typeof StateTaskEither_;
}
export { TaskOption } from "fp-ts-contrib/lib/TaskOption";
import * as TaskOption_ from "fp-ts-contrib/lib/TaskOption";
declare module "./Generated" {
const TaskOption: typeof TaskOption_;
}
export { Zipper } from "fp-ts-contrib/lib/Zipper";
import * as Zipper_ from "fp-ts-contrib/lib/Zipper";
declare module "./Generated" {
const Zipper: typeof Zipper_;
}
import * as ArrayOption_ from "fp-ts-contrib/lib/ArrayOption";
exports.ArrayOption = ArrayOption_;
import * as Free_ from "fp-ts-contrib/lib/Free";
exports.Free = Free_;
import * as IOOption_ from "fp-ts-contrib/lib/IOOption";
exports.IOOption = IOOption_;
import * as List_ from "fp-ts-contrib/lib/List";
exports.List = List_;
import * as ReaderIO_ from "fp-ts-contrib/lib/ReaderIO";
exports.ReaderIO = ReaderIO_;
import * as RegExp_ from "fp-ts-contrib/lib/RegExp";
exports.RegExp = RegExp_;
import * as StateEither_ from "fp-ts-contrib/lib/StateEither";
exports.StateEither = StateEither_;
import * as StateIO_ from "fp-ts-contrib/lib/StateIO";
exports.StateIO = StateIO_;
import * as StateTaskEither_ from "fp-ts-contrib/lib/StateTaskEither";
exports.StateTaskEither = StateTaskEither_;
import * as TaskOption_ from "fp-ts-contrib/lib/TaskOption";
exports.TaskOption = TaskOption_;
import * as Zipper_ from "fp-ts-contrib/lib/Zipper";
exports.Zipper = Zipper_;
//# sourceMappingURL=Generated.js.map
{"version":3,"file":"Generated.js","sourceRoot":"","sources":["../../src/Generated.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,YAAY,MAAM,+BAA+B,CAAC;AAC9D,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC;AAMnC,OAAO,KAAK,KAAK,MAAM,wBAAwB,CAAC;AAChD,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC;AAMrB,OAAO,KAAK,SAAS,MAAM,4BAA4B,CAAC;AACxD,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;AAM7B,OAAO,KAAK,KAAK,MAAM,wBAAwB,CAAC;AAChD,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC;AAMrB,OAAO,KAAK,SAAS,MAAM,4BAA4B,CAAC;AACxD,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;AAK7B,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAC;AACpD,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC;AAMzB,OAAO,KAAK,YAAY,MAAM,+BAA+B,CAAC;AAC9D,OAAO,CAAC,WAAW,GAAG,YAAY,CAAC;AAMnC,OAAO,KAAK,QAAQ,MAAM,2BAA2B,CAAC;AACtD,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC;AAM3B,OAAO,KAAK,gBAAgB,MAAM,mCAAmC,CAAC;AACtE,OAAO,CAAC,eAAe,GAAG,gBAAgB,CAAC;AAM3C,OAAO,KAAK,WAAW,MAAM,8BAA8B,CAAC;AAC5D,OAAO,CAAC,UAAU,GAAG,WAAW,CAAC;AAMjC,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAC;AACpD,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC"}
export * from "./Generated";
export * as JSON from "./JSON";
export { Do } from "./Do";
export * as Exception from "./Exception";
export * from "./Generated";
import * as JSON_1 from "./JSON";
export { JSON_1 as JSON };
export { Do } from "./Do";
import * as Exception_1 from "./Exception";
export { Exception_1 as Exception };
//# sourceMappingURL=index.js.map
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;wBACN,QAAQ;mBAAlB,IAAI;AAChB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;6BACC,aAAa;wBAA5B,SAAS"}
import { Either } from "@morphism/fp";
export declare const parse: (string: string) => Either<Error, unknown>;
export declare namespace Stringify {
const short: (json: unknown) => Either<Error, string>;
const pretty: (json: unknown) => Either<Error, string>;
namespace Always {
const short: (json: unknown) => string;
const pretty: (json: unknown) => string;
}
}
import { Either, pipe, Identity } from "@morphism/fp";
export var parse = function (string) {
return Either.parseJSON(string, onError);
};
export var Stringify;
(function (Stringify) {
Stringify.short = function (json) {
return Either.tryCatch(function () { return JSON.stringify(json); }, onError);
};
Stringify.pretty = function (json) {
return Either.tryCatch(function () { return JSON.stringify(json, undefined, 2); }, onError);
};
var Always;
(function (Always) {
Always.short = function (json) {
return pipe(Stringify.short(json), Either.fold(defaultJSON, Identity.of));
};
Always.pretty = function (json) {
return pipe(Stringify.pretty(json), Either.fold(defaultJSON, Identity.of));
};
var defaultJSON = function () { return "{}"; };
})(Always = Stringify.Always || (Stringify.Always = {}));
})(Stringify || (Stringify = {}));
var onError = function (error) {
return Error("Unrepresentable JSON value...\n\n" + error);
};
//# sourceMappingURL=JSON.js.map
{"version":3,"file":"JSON.js","sourceRoot":"","sources":["../../src/JSON.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,CAAC,IAAM,KAAK,GAAG,UAAC,MAAc;IAClC,OAAA,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC;AAAjC,CAAiC,CAAC;AAEpC,MAAM,KAAW,SAAS,CAgBzB;AAhBD,WAAiB,SAAS;IACX,eAAK,GAAG,UAAC,IAAa;QACjC,OAAA,MAAM,CAAC,QAAQ,CAAC,cAAM,OAAA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAApB,CAAoB,EAAE,OAAO,CAAC;IAApD,CAAoD,CAAC;IAE1C,gBAAM,GAAG,UAAC,IAAa;QAClC,OAAA,MAAM,CAAC,QAAQ,CAAC,cAAM,OAAA,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,EAAlC,CAAkC,EAAE,OAAO,CAAC;IAAlE,CAAkE,CAAC;IAErE,IAAiB,MAAM,CAQtB;IARD,WAAiB,MAAM;QACR,YAAK,GAAG,UAAC,IAAa;YACjC,OAAA,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;QAAlE,CAAkE,CAAC;QAExD,aAAM,GAAG,UAAC,IAAa;YAClC,OAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;QAAnE,CAAmE,CAAC;QAEtE,IAAM,WAAW,GAAG,cAAc,OAAA,IAAI,EAAJ,CAAI,CAAC;IACzC,CAAC,EARgB,MAAM,GAAN,gBAAM,KAAN,gBAAM,QAQtB;AACH,CAAC,EAhBgB,SAAS,KAAT,SAAS,QAgBzB;AAED,IAAM,OAAO,GAAG,UAAC,KAAc;IAC7B,OAAA,KAAK,CAAC,sCAAoC,KAAO,CAAC;AAAlD,CAAkD,CAAC"}