@most/disposable
Advanced tools
Comparing version 0.13.0 to 0.13.1
@@ -0,1 +1,3 @@ | ||
import { curry2, curry3, reduce } from '@most/prelude'; | ||
/** @license MIT License (c) copyright 2010-2017 original author or authors */ | ||
@@ -35,43 +37,2 @@ | ||
/** @license MIT License (c) copyright 2010-2016 original author or authors */ | ||
// Non-mutating array operations | ||
// cons :: a -> [a] -> [a] | ||
// a with x prepended | ||
// reduce :: (a -> b -> a) -> a -> [b] -> a | ||
// accumulate via left-fold | ||
function reduce (f, z, a) { | ||
var r = z; | ||
for (var i = 0, l = a.length; i < l; ++i) { | ||
r = f(r, a[i], i); | ||
} | ||
return r | ||
} | ||
// curry2 :: ((a, b) -> c) -> (a -> b -> c) | ||
function curry2 (f) { | ||
function curried (a, b) { | ||
switch (arguments.length) { | ||
case 0: return curried | ||
case 1: return function (b) { return f(a, b); } | ||
default: return f(a, b) | ||
} | ||
} | ||
return curried | ||
} | ||
// curry3 :: ((a, b, c) -> d) -> (a -> b -> c -> d) | ||
function curry3 (f) { | ||
function curried (a, b, c) { // eslint-disable-line complexity | ||
switch (arguments.length) { | ||
case 0: return curried | ||
case 1: return curry2(function (b, c) { return f(a, b, c); }) | ||
case 2: return function (c) { return f(a, b, c); } | ||
default:return f(a, b, c) | ||
} | ||
} | ||
return curried | ||
} | ||
/** @license MIT License (c) copyright 2010-2017 original author or authors */ | ||
@@ -78,0 +39,0 @@ // Create a Disposable that will use the provided |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.mostDisposable = global.mostDisposable || {}))); | ||
}(this, (function (exports) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@most/prelude')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@most/prelude'], factory) : | ||
(factory((global.mostDisposable = global.mostDisposable || {}),global.mostPrelude)); | ||
}(this, (function (exports,_most_prelude) { 'use strict'; | ||
@@ -41,47 +41,6 @@ /** @license MIT License (c) copyright 2010-2017 original author or authors */ | ||
/** @license MIT License (c) copyright 2010-2016 original author or authors */ | ||
// Non-mutating array operations | ||
// cons :: a -> [a] -> [a] | ||
// a with x prepended | ||
// reduce :: (a -> b -> a) -> a -> [b] -> a | ||
// accumulate via left-fold | ||
function reduce (f, z, a) { | ||
var r = z; | ||
for (var i = 0, l = a.length; i < l; ++i) { | ||
r = f(r, a[i], i); | ||
} | ||
return r | ||
} | ||
// curry2 :: ((a, b) -> c) -> (a -> b -> c) | ||
function curry2 (f) { | ||
function curried (a, b) { | ||
switch (arguments.length) { | ||
case 0: return curried | ||
case 1: return function (b) { return f(a, b); } | ||
default: return f(a, b) | ||
} | ||
} | ||
return curried | ||
} | ||
// curry3 :: ((a, b, c) -> d) -> (a -> b -> c -> d) | ||
function curry3 (f) { | ||
function curried (a, b, c) { // eslint-disable-line complexity | ||
switch (arguments.length) { | ||
case 0: return curried | ||
case 1: return curry2(function (b, c) { return f(a, b, c); }) | ||
case 2: return function (c) { return f(a, b, c); } | ||
default:return f(a, b, c) | ||
} | ||
} | ||
return curried | ||
} | ||
/** @license MIT License (c) copyright 2010-2017 original author or authors */ | ||
// Create a Disposable that will use the provided | ||
// dispose function to dispose the resource | ||
var disposeWith = curry2(function (dispose, resource) { return disposeOnce(new DisposeWith(dispose, resource)); }); | ||
var disposeWith = _most_prelude.curry2(function (dispose, resource) { return disposeOnce(new DisposeWith(dispose, resource)); }); | ||
@@ -106,3 +65,3 @@ // Disposable represents a resource that must be | ||
// Convenience to aggregate 2 disposables | ||
var disposeBoth = curry2(function (d1, d2) { return disposeAll([d1, d2]); }); | ||
var disposeBoth = _most_prelude.curry2(function (d1, d2) { return disposeAll([d1, d2]); }); | ||
@@ -118,3 +77,3 @@ var DisposeAll = function DisposeAll (disposables) { | ||
// Dispose all, safely collecting errors into an array | ||
var disposeCollectErrors = function (disposables) { return reduce(appendIfError, [], disposables); }; | ||
var disposeCollectErrors = function (disposables) { return _most_prelude.reduce(appendIfError, [], disposables); }; | ||
@@ -164,3 +123,3 @@ // Call dispose and if throws, append thrown error to errors | ||
var formatErrorStacks = function (errors) { return reduce(formatErrorStack, '', errors); }; | ||
var formatErrorStacks = function (errors) { return _most_prelude.reduce(formatErrorStack, '', errors); }; | ||
@@ -172,3 +131,3 @@ var formatErrorStack = function (s, e, i) { return s + "\n[" + ((i + 1)) + "] " + (e.stack); }; | ||
// the error to sink.error with the provided Time value | ||
var tryDispose = curry3(function (t, disposable, sink) { | ||
var tryDispose = _most_prelude.curry3(function (t, disposable, sink) { | ||
try { | ||
@@ -175,0 +134,0 @@ disposable.dispose(); |
{ | ||
"name": "@most/disposable", | ||
"version": "0.13.0", | ||
"version": "0.13.1", | ||
"description": "Reactive programming with lean, functions-only, curried, tree-shakeable API", | ||
@@ -50,3 +50,2 @@ "typings": "type-definitions/index.d.ts", | ||
"rollup-plugin-buble": "^0.15.0", | ||
"rollup-plugin-node-resolve": "^2.0.0", | ||
"sinon": "^1.17.7", | ||
@@ -53,0 +52,0 @@ "snazzy": "^7.0.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12
28016
232