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

cb-buffer

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cb-buffer - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

155

lib/index.js
"use strict";
module.exports = class CbBuffer {
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
module.exports = function () {
/**

@@ -20,3 +24,5 @@ * CbBuffer

*/
constructor () {
function CbBuffer() {
_classCallCheck(this, CbBuffer);
// The functions buffer

@@ -40,72 +46,95 @@ this.buffer = [];

*/
check (fn) {
if (this.is_done) {
this.call(fn);
return true;
_createClass(CbBuffer, [{
key: "check",
value: function check(fn) {
if (this.is_done) {
this.call(fn);
return true;
}
this.buffer.push(fn);
if (this.waiting) {
return true;
} else {
this.waiting = true;
}
return false;
}
this.buffer.push(fn);
if (this.waiting) {
return true;
} else {
this.waiting = true;
/**
* call
* Calls the provided function with the callback arguments.
*
* @name call
* @function
* @param {Function} fn The function to call.
*/
}, {
key: "call",
value: function call(fn) {
fn.apply(this, this.args);
}
return false;
}
/**
* clear
* CLears the callback array.
*
* @name clear
* @function
*/
/**
* call
* Calls the provided function with the callback arguments.
*
* @name call
* @function
* @param {Function} fn The function to call.
*/
call (fn) {
fn.apply(this, this.args);
}
}, {
key: "clear",
value: function clear() {
this.buffer = [];
}
/**
* clear
* CLears the callback array.
*
* @name clear
* @function
*/
clear () {
this.buffer = [];
}
/**
* undone
* Resets the internal data.
*
* @name undone
* @function
*/
/**
* undone
* Resets the internal data.
*
* @name undone
* @function
*/
undone () {
// Waiting: false/true
this.waiting = false;
}, {
key: "undone",
value: function undone() {
// Waiting: false/true
this.waiting = false;
// Is done: false/true
this.is_done = false;
// Is done: false/true
this.is_done = false;
// This will be the callback arguments array
this.args = [];
}
// This will be the callback arguments array
this.args = [];
}
/**
* done
* Calls all the functions from the buffer.
*
* @name done
* @function
*/
done () {
this.is_done = true;
this.args = arguments;
this.buffer.forEach(fn => this.call(fn));
this.clear();
}
};
/**
* done
* Calls all the functions from the buffer.
*
* @name done
* @function
*/
}, {
key: "done",
value: function done() {
var _this = this;
this.is_done = true;
this.args = arguments;
this.buffer.forEach(function (fn) {
return _this.call(fn);
});
this.clear();
}
}]);
return CbBuffer;
}();
{
"name": "cb-buffer",
"version": "2.1.0",
"version": "2.1.1",
"description": "A minimalist NodeJS module for callback buffering.",

@@ -16,3 +16,3 @@ "main": "lib/index.js",

],
"author": "jillix <contact@jillix.com> (http://jillix.com)",
"author": "Ionică Bizău <bizauionica@gmail.com> (https://ionicabizau.net)",
"contributors": [

@@ -24,11 +24,22 @@ "Ionică Bizău <bizauionica@gmail.com> (http://ionicabizau.net)"

"type": "git",
"url": "git+ssh://git@github.com/jillix/node-cb-buffer.git"
"url": "git+ssh://git@github.com/IonicaBizau/cb-buffer.git"
},
"bugs": {
"url": "https://github.com/jillix/node-cb-buffer/issues"
"url": "https://github.com/IonicaBizau/cb-buffer/issues"
},
"homepage": "https://github.com/jillix/node-cb-buffer",
"homepage": "https://github.com/IonicaBizau/cb-buffer",
"blah": {
"h_img": "http://i.imgur.com/UjN9LfL.png"
}
}
},
"files": [
"bin/",
"app/",
"lib/",
"dist/",
"src/",
"resources/",
"menu/",
"cli.js",
"index.js"
]
}

@@ -0,9 +1,12 @@

[![cb-buffer](http://i.imgur.com/UjN9LfL.png)](#)
# cb-buffer [![Version](https://img.shields.io/npm/v/cb-buffer.svg)](https://www.npmjs.com/package/cb-buffer) [![Downloads](https://img.shields.io/npm/dt/cb-buffer.svg)](https://www.npmjs.com/package/cb-buffer)
# cb-buffer
[![Patreon](https://img.shields.io/badge/Support%20me%20on-Patreon-%23e6461a.svg)][patreon] [![PayPal](https://img.shields.io/badge/%24-paypal-f39c12.svg)][paypal-donations] [![AMA](https://img.shields.io/badge/ask%20me-anything-1abc9c.svg)](https://github.com/IonicaBizau/ama) [![Version](https://img.shields.io/npm/v/cb-buffer.svg)](https://www.npmjs.com/package/cb-buffer) [![Downloads](https://img.shields.io/npm/dt/cb-buffer.svg)](https://www.npmjs.com/package/cb-buffer) [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github)
> A minimalist NodeJS module for callback buffering.
## :cloud: Installation
```sh

@@ -13,7 +16,7 @@ $ npm i --save cb-buffer

## :clipboard: Example
```js

@@ -54,5 +57,6 @@ // Dependencies

```
## :memo: Documentation
### `CbBuffer()`

@@ -99,9 +103,21 @@ Creates a new instance of `CbBuffer`.

## :yum: How to contribute
Have an idea? Found a bug? See [how to contribute][contributing].
## :moneybag: Donations
Another way to support the development of my open-source modules is
to [set up a recurring donation, via Patreon][patreon]. :rocket:
[PayPal donations][paypal-donations] are appreciated too! Each dollar helps.
Thanks! :heart:
## :dizzy: Where is this library used?
If you are using this library in one of your projects, add it in this list. :sparkles:
- [`bible.js`](https://github.com/BibleJS/bible.js)—The Bible as a NPM module.

@@ -112,8 +128,12 @@ - [`cb-bufferify`](https://github.com/IonicaBizau/cb-bufferify#readme)—Convert any async function to a cb-buffer handler.

## :scroll: License
[MIT][license] © [jillix][website]
[license]: http://showalicense.com/?fullname=jillix%20%3Ccontact%40jillix.com%3E%20(http%3A%2F%2Fjillix.com)&year=2014#license-mit
[website]: http://jillix.com
[MIT][license] © [Ionică Bizău][website]
[patreon]: https://www.patreon.com/ionicabizau
[paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RVXDDLKKLQRJW
[donate-now]: http://i.imgur.com/6cMbHOC.png
[license]: http://showalicense.com/?fullname=Ionic%C4%83%20Biz%C4%83u%20%3Cbizauionica%40gmail.com%3E%20(https%3A%2F%2Fionicabizau.net)&year=2014#license-mit
[website]: https://ionicabizau.net
[contributing]: /CONTRIBUTING.md
[docs]: /DOCUMENTATION.md
[docs]: /DOCUMENTATION.md

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