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

yaku

Package Overview
Dependencies
Maintainers
1
Versions
137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yaku - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

50

lib/utils.js
/*
Yaku v0.5.0
Yaku v0.6.0
(c) 2015 Yad Smood. http://ysmood.org

@@ -411,3 +411,4 @@ License MIT

*
* handlers: Array
* // All the children spawned from current source.
* children: Array
* }

@@ -430,3 +431,3 @@ * ```

*
* another = linear.on(x => -x);
* var another = linear.on(x => -x);
*

@@ -438,6 +439,10 @@ * quad.on(

*
* // Dispose all children. You can also dispose some specific handlers.
* linear.handlers = [];
* // Dispose a specific source.
* linear.children.splice(linear.children.indexOf(quad));
*
* // Dispose all children.
* linear.children = [];
* ```
* @example
* Use it with DOM.
* ```js

@@ -457,2 +462,12 @@ * var filter = fn => v => fn(v) ? v : utils.end();

* ```
* @example
* Merge two sources into one.
* ```js
* let one = utils.source(emit => setInterval(emit, 100, 'one'));
* let two = utils.source(emit => setInterval(emit, 200, 'two'));
* let merge = arr => arr.forEach(src => src.on(emit));
*
* let three = merge([one, two]);
* three.on(v => console.log(v));
* ```
*/

@@ -462,8 +477,8 @@ source: function(executor) {

src = function(val) {
var handler, j, len, ref;
var child, j, len, ref;
src.value = val = Promise.resolve(val);
ref = src.handlers;
ref = src.children;
for (j = 0, len = ref.length; j < len; j++) {
handler = ref[j];
val.then(handler.onEmit, handler.onError).then(handler.nextSrc, handler.nextSrcErr);
child = ref[j];
val.then(child.onEmit, child.onError).then(child, child.nextSrcErr);
}

@@ -473,14 +488,11 @@ };

var nextSrc;
nextSrc = utils.source();
src.handlers.push({
onEmit: onEmit,
onError: onError,
nextSrc: nextSrc,
nextSrcErr: function(reason) {
return nextSrc(Promise.reject(reason));
}
});
src.children.push(nextSrc = utils.source());
nextSrc.onEmit = onEmit;
nextSrc.onError = onError;
nextSrc.nextSrcErr = function(reason) {
return nextSrc(Promise.reject(reason));
};
return nextSrc;
};
src.handlers = [];
src.children = [];
src.value = Promise.resolve();

@@ -487,0 +499,0 @@ if (typeof executor === "function") {

/*
Yaku v0.5.0
Yaku v0.6.0
(c) 2015 Yad Smood. http://ysmood.org

@@ -75,3 +75,3 @@ License MIT

*/
Yaku = function Yaku (executor) {
Yaku = function (executor) {
var self = this,

@@ -78,0 +78,0 @@ err;

{
"name": "yaku",
"version": "0.5.0",
"version": "0.6.0",
"description": "An ES6 Promises/A+ implementation that doesn't hurt.",

@@ -5,0 +5,0 @@ "main": "lib/yaku.js",

@@ -187,3 +187,3 @@ <a href="http://promisesaplus.com/">

- ### **[Yaku.resolve(onRejected, value)](src/yaku.js?source#L152)**
- ### **[catch(onRejected)](src/yaku.js?source#L125)**

@@ -212,22 +212,9 @@ The `catch()` method returns a Promise and deals with rejected cases only.

```
/
"catch": function (onRejected) {
return this.then($nil, onRejected);
},
// Default state
_state: $pending,
- ### **[Yaku.resolve(value)](src/yaku.js?source#L152)**
// The number of current promises that attach to this Yaku instance.
_pCount: 0,
The `Promise.resolve(value)` method returns a Promise object that is resolved with the given value.
If the value is a thenable (i.e. has a then method), the returned promise will "follow" that thenable,
adopting its eventual state; otherwise the returned promise will be fulfilled with the value.
// The parent Yaku.
_pre: null
};
/**
The `Promise.resolve(value)` method returns a Promise object that is resolved with the given value.
If the value is a thenable (i.e. has a then method), the returned promise will "follow" that thenable,
adopting its eventual state; otherwise the returned promise will be fulfilled with the value.
- **<u>param</u>**: `value` { _Any_ }

@@ -396,3 +383,3 @@

To use it you have to require it separately: `utils = require 'yaku/lib/utils'`.
To use it you have to require it separately: `yutils = require 'yaku/lib/utils'`.
If you want to use it in the browser, you have to use `browserify` or `webpack`.

@@ -622,3 +609,3 @@

- ### **[source(executor)](src/utils.coffee?source#L395)**
- ### **[source(executor)](src/utils.coffee?source#L410)**

@@ -644,3 +631,4 @@ Create a composable event source function.

handlers: Array
// All the children spawned from current source.
children: Array
}

@@ -665,3 +653,3 @@ ```

another = linear.on(x => -x);
var another = linear.on(x => -x);

@@ -673,4 +661,7 @@ quad.on(

// Dispose all children. You can also dispose some specific handlers.
linear.handlers = [];
// Dispose a specific source.
linear.children.splice(linear.children.indexOf(quad));
// Dispose all children.
linear.children = [];
```

@@ -680,2 +671,3 @@

Use it with DOM.
```js

@@ -696,4 +688,16 @@ var filter = fn => v => fn(v) ? v : utils.end();

- ### **[throw(err)](src/utils.coffee?source#L438)**
- **<u>example</u>**:
Merge two sources into one.
```js
let one = utils.source(emit => setInterval(emit, 100, 'one'));
let two = utils.source(emit => setInterval(emit, 200, 'two'));
let merge = arr => arr.forEach(src => src.on(emit));
let three = merge([one, two]);
three.on(v => console.log(v));
```
- ### **[throw(err)](src/utils.coffee?source#L450)**
Throw an error to break the program.

@@ -700,0 +704,0 @@

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