Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongot

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongot - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

1

build/cursor.d.ts

@@ -22,4 +22,5 @@ /// <reference types="node" />

}): this;
hasNext(): Promise<boolean>;
fetch(): Promise<T>;
fetchAll(): Promise<T[]>;
}

73

build/cursor.js
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments)).next());
});
};
const events_1 = require("events");

@@ -14,6 +22,2 @@ class Cursor extends events_1.EventEmitter {

this.cursor = cursor;
this.cursor.on('data', document => this.emit('data', document));
this.cursor.on('error', err => this.emit('error', err));
this.cursor.on('end', () => this.emit('end'));
this.cursor.on('readable', () => this.emit('readable'));
}

@@ -54,50 +58,23 @@ clone() {

}
hasNext() {
return __awaiter(this, void 0, void 0, function* () {
return this.cursor.hasNext();
});
}
fetch() {
return new Promise((resolve, reject) => {
this.cursor.hasNext((err, hasNext) => {
if (err) {
reject(err);
}
else if (hasNext) {
this.cursor.next((err, document) => {
if (err) {
reject(err);
}
else {
resolve(document);
}
});
}
else {
this.rewind();
resolve();
}
});
return __awaiter(this, void 0, void 0, function* () {
if (yield this.cursor.hasNext()) {
return yield this.cursor.next();
}
return null;
});
}
fetchAll() {
this.rewind();
return new Promise((resolve, reject) => {
const data = [];
const next = () => {
this.cursor.hasNext((err, hasNext) => {
if (err) {
return reject(err);
}
if (hasNext) {
this.cursor.next((err, document) => {
if (err) {
return reject(err);
}
data.push(document);
next();
});
}
else {
this.rewind();
resolve(data);
}
});
};
next();
return __awaiter(this, void 0, void 0, function* () {
this.rewind();
const result = [];
while (yield this.cursor.hasNext()) {
result.push(yield this.cursor.next());
}
return result;
});

@@ -104,0 +81,0 @@ }

{
"name": "mongot",
"version": "0.2.4",
"version": "0.2.5",
"description": "A lightweight typed MongoDb library for TypeScript.",

@@ -5,0 +5,0 @@ "main": "build/index.js",

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