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

penseur

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

penseur - npm Package Compare versions

Comparing version 8.0.2 to 8.1.0

91

lib/table.js

@@ -271,48 +271,71 @@ 'use strict';

if (Array.isArray(ids)) {
Hoek.assert(ids.length, 'Cannot pass empty array');
// (id, changes)
if (!changes) { // (updates)
changes = ids;
ids = changes.map((item) => item.id);
}
else {
if (typeof ids[0] === 'object') { // (updates, options)
const options = changes;
changes = ids;
if (!Array.isArray(ids)) {
Hoek.assert(changes && typeof changes === 'object', 'Invalid changes object');
return this._update(ids, changes, track);
}
if (options.chunks &&
changes.length !== 1) {
if (!ids.length) {
return;
}
// Split items into batches
// (updates)
const batches = [];
let left = changes;
while (left.length) {
batches.push(left.slice(0, options.chunks));
left = left.slice(options.chunks);
}
if (!changes) {
const updates = ids;
return this._update(updates.map((item) => item.id), updates, track);
}
for (let i = 0; i < batches.length; ++i) {
const batch = batches[i];
await this._update(batch.map((item) => item.id), batch, track);
}
// ([ids], changes)
return;
}
if (typeof ids[0] !== 'object') {
Hoek.assert(!Array.isArray(changes), 'Changes cannot be an array when ids is an array');
return this._update(ids, changes, track);
}
ids = changes.map((item) => item.id);
}
else { // (ids, changes)
Hoek.assert(!Array.isArray(changes), 'Changes cannot be an array when ids is an array');
}
}
// ([updates], options)
const options = changes;
changes = ids;
if (!options.chunks ||
changes.length <= options.chunks) {
ids = changes.map((item) => item.id);
return this._update(ids, changes, track);
}
else { // (id, changes)
Hoek.assert(changes && typeof changes === 'object', 'Invalid changes object');
// Split items into batches
const batches = [];
let left = changes;
while (left.length) {
batches.push(left.slice(0, options.chunks));
left = left.slice(options.chunks);
}
return this._update(ids, changes, track);
for (let i = 0; i < batches.length; ++i) {
const batch = batches[i];
await this._update(batch.map((item) => item.id), batch, track);
}
}
static items(ids, changes) {
// (id, changes)
// ([ids], changes)
if (!Array.isArray(ids) ||
(ids[0] && typeof ids[0] !== 'object')) {
return [changes];
}
// ([updates])
// ([updates], options)
return ids;
}
async _update(ids, changes, track) {

@@ -319,0 +342,0 @@

{
"name": "penseur",
"description": "Lightweight RethinkDB wrapper",
"version": "8.0.2",
"version": "8.1.0",
"author": "Eran Hammer <eran@hammer.io> (http://hueniverse.com)",

@@ -6,0 +6,0 @@ "repository": "git://github.com/hueniverse/penseur",

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