Socket
Socket
Sign inDemoInstall

nedb-async

Package Overview
Dependencies
103
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.4 to 0.1.5

44

dist/util.js

@@ -25,35 +25,16 @@ "use strict";

let count = 1;
// @ts-ignore
for (const modify of modifies) {
for (const [method, value] of modifies) {
const valid = ['sort', 'limit', 'skip'];
if (valid.indexOf(modify[0]) === -1) {
throw new Error(`${modify[0]} is not recognize, available methods are ${valid.join(',')}`);
if (valid.includes(method)) {
throw new Error(`${method} is not recognized, available methods are ${valid.join(',')}`);
}
if (typeof modify[0] !== 'string') {
throw new Error(`${modify[0]} must be a type of string, available methods are ${valid.join(',')}`);
if (typeof method !== 'string') {
throw new Error(`${method} must be a type of string, available methods are ${valid.join(',')}`);
}
/**
* If this modify is the last
* element of the modifies
* array append exec method
* the modify array contains
* two elements, first element
* being the method name while
* the last element the method
* argument
* ['sort',{name: -1, createdAt: -1}]
* and so on
*/
// call exec method if it's the last
if (count === arg.length) {
cursor[modify[0]](modify[1]).exec((err, docs) => {
if (err) {
rj(err);
}
else {
rs(docs);
}
});
cursor[method](value).exec((err, docs) => (err ? rj(err) : rs(docs)));
}
else {
cursor[modify[0]](modify[1]);
cursor[method](value);
}

@@ -65,10 +46,3 @@ count++;

// @ts-ignore
this[name](...arg, (err, docs) => {
if (err) {
rj(err);
}
else {
rs(docs);
}
});
this[name](...arg, (err, docs) => (err ? rj(err) : rs(docs)));
}

@@ -75,0 +49,0 @@ });

{
"name": "nedb-async",
"version": "0.1.4",
"version": "0.1.5",
"description": "Promise wrapper for Nedb that makes it possible to use all Nedb all cursor modifiers.",

@@ -5,0 +5,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc