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

result

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

result - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

defer.js

69

index.js
var ResType = require('result-type')
, unhandled = require('unhandled')
, nextTick = require('next-tick')

@@ -46,5 +47,5 @@ , inherit = require('inherit')

case 'fail':
Result.onCatch && Result.onCatch(this)
if (!onError) throw this.value
onError(this.value)
unhandled.remove(this.value)
if (onError) onError(this.value)
else thrower(this.value)
}

@@ -93,10 +94,7 @@ return this

var i = 1
if (child) {
do {
if (!child._onError) child.error(reason)
else propagate(child, child._onError, reason)
} while (child = this[i++])
return this
}
Result.onError && Result.onError(this, reason)
if (child) do {
if (!child._onError) child.error(reason)
else propagate(child, child._onError, reason)
} while (child = this[i++])
else unhandled(reason)
}

@@ -150,7 +148,5 @@ return this

case 'fail':
if (onError) {
Result.onCatch && Result.onCatch(this)
return run(onError, this.value)
}
return failed(this.value)
if (!onError) return failed(this.value)
unhandled.remove(this.value)
return run(onError, this.value)
}

@@ -170,7 +166,3 @@ }

try { var result = handler(value) }
catch (e) {
result = failed(e)
Result.onError && Result.onError(result, e)
return result
}
catch (e) { return failed(e) }

@@ -269,37 +261,2 @@ if (result instanceof ResType) {

return this.then(function(){ return value })
}
/**
* Called when a Result enters the "fail" state without
* any readers to pass the `error` to
*
* @param {Result} result
* @param {x} error
*/
Result.onError = function(result, error){
result._throw = setTimeout(function(){
if (error instanceof Error) {
error.message += ' (from a "failed" Result)'
throw error
}
if (typeof console == 'object') {
console.warn('%s (from a "failed" Result)', error)
}
}, 1000)
}
/**
* Called when a Result in "fail" state has `read`
* or `then` called with and `onError` handler i.e.
* when a failed result is handled
*
* @param {Result} result
*/
Result.onCatch = function(result){
if (result._throw !== undefined) {
clearTimeout(result._throw)
result._throw = undefined
}
}
{
"name": "result",
"version": "0.2.0",
"version": "0.3.0",
"description": "reify your results",

@@ -8,3 +8,4 @@ "dependencies": {

"next-tick": "timoxley/next-tick",
"result-type": "1.0.0"
"result-type": "1.0.0",
"unhandled": "0.1.0"
},

@@ -19,5 +20,12 @@ "devDependencies": {},

},
"keywords": ["result","computation","promise","future","thenable","reify"],
"keywords": [
"result",
"computation",
"promise",
"future",
"thenable",
"reify"
],
"author": "Jake Rosoman",
"license": "MIT"
}

@@ -30,3 +30,3 @@

var Result = require('result')
var defer = require('result/lazy')
var defer = require('result/defer')
```

@@ -102,7 +102,3 @@

create a DeferredResult which is associated with procedure `ƒ`.
`ƒ` will only be evaluated once someone actually reads from the
DeferredResult. `then` returns a normal Result so from there on
out you revert to eager evaluation. For a fully fledged lazy
evaluation strategy [see](//github.com/jkroso/lazy-result).
create a DeferredResult which is associated with procedure `ƒ`. `ƒ` will only be evaluated only once someone actually reads from the DeferredResult. `then` returns a normal Result so from there on out you revert to eager evaluation. For a fully fledged lazy evaluation strategy [see](//github.com/jkroso/lazy-result).

@@ -109,0 +105,0 @@ ```js

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