Socket
Socket
Sign inDemoInstall

fibers

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fibers - npm Package Compare versions

Comparing version 0.6.4 to 0.6.5

man/fibers.1

69

future.js

@@ -123,3 +123,23 @@ "use strict";

} else if (this.error) {
throw this.error;
// Link the stack traces up
var stack = {}, error = this.error instanceof Object ? this.error : new Error(this.error);
var longError = Object.create(error);
Error.captureStackTrace(stack, Future.prototype.get);
Object.defineProperty(longError, 'stack', {
get: function() {
var baseStack = error.stack;
if (baseStack) {
baseStack = baseStack.split('\n');
return [baseStack[0]]
.concat(stack.stack.split('\n').slice(1))
.concat(' - - - - -')
.concat(baseStack.slice(1))
.join('\n');
} else {
return stack.stack;
}
},
enumerable: true,
});
throw longError;
} else {

@@ -145,3 +165,8 @@ return this.value;

try {
callbacks[ii](undefined, value);
var ref = callbacks[ii];
if (ref[1]) {
ref[1](value);
} else {
ref[0](undefined, value);
}
} catch(ex) {

@@ -172,3 +197,8 @@ console.log(String(ex.stack || ex.message || ex));

try {
callbacks[ii](error);
var ref = callbacks[ii];
if (ref[1]) {
ref[0].throw(error);
} else {
ref[0](error);
}
} catch(ex) {

@@ -183,2 +213,16 @@ console.log(ex.stack || ex);

/**
* "detach" this future. Basically this is useful if you want to run a task in a future, you
* aren't interested in its return value, but if it throws you don't want the exception to be
* lost. If this fiber throws, an exception will be thrown to the event loop and node will
* probably fall down.
*/
detach: function() {
this.resolve(function(err) {
if (err) {
throw err;
}
});
},
/**
* Returns whether or not this future has resolved yet.

@@ -205,8 +249,21 @@ */

* Waits for this future to resolve and then invokes a callback.
*
* If two arguments are passed, the first argument is a future which will be thrown to in the case
* of error, and the second is a function(val){} callback.
*
* If only one argument is passed it is a standard function(err, val){} callback.
*/
resolve: function(cb) {
resolve: function(arg1, arg2) {
if (this.resolved) {
cb(this.error, this.value);
if (arg2) {
if (this.error) {
arg1.throw(this.error);
} else {
arg2(this.value);
}
} else {
arg1(this.error, this.value);
}
} else {
(this.callbacks = this.callbacks || []).push(cb);
(this.callbacks = this.callbacks || []).push([arg1, arg2]);
}

@@ -213,0 +270,0 @@ return this;

4

package.json
{
"name": "fibers",
"version": "0.6.4",
"version": "0.6.5",
"description": "Cooperative multi-tasking for Javascript; or, the closest thing to a thread you'll see in node",

@@ -18,3 +18,3 @@ "keywords": [

},
"os": ["macos", "linux"],
"os": ["darwin", "linux"],
"engines": {

@@ -21,0 +21,0 @@ "node": ">=0.5.2"

require('fibers');
var fibers = [];
for (var jj = 0; jj < 10; ++jj) {
var fibers = [];
for (var ii = 0; ii < 200; ++ii) {

@@ -6,0 +6,0 @@ var fn = Fiber(function() {

// gh-10
require('fibers');
var title = process.title;
Fiber(function() {
process.title = 'pass';
}).run();
// sunos process.title doesn't work, regardless of fibers
console.log(process.platform === 'sunos' ? 'pass' : process.title);
console.log(process.title === 'pass' || process.title === title ? 'pass' : 'fail');

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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