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

hyper-analytics

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyper-analytics - npm Package Compare versions

Comparing version 0.11.7 to 0.11.8

85

js/DataSource.js

@@ -41,7 +41,84 @@ 'use strict';

findRow: function(columnName, value) {
var result;
if (value != null) {
result = this.data.find(function(row) { return row[columnName] === value; });
/**
* @summary Find, replace, or update a row by it's primary key column.
* @param {string|object} columnName - One of:
* * _string_ - Column name. See `value`.
* * _object_ - Hash of 0 or more key-value pairs to search for.
* @param {string[]|*} [value] - One of:
* _omitted_ - When `columnName` is a hash and you want to search all its keys.
* _string[]_ - When `columnName` is a hash but you only want to search certain keys.
* _otherwise_ - When `columnName` is a string. Value to search for.
* Note that `null` is a valid search value.
* @param {object|null|undefined} [replacement] - One of:
* * _omitted_ - Ignored.
* * _object_ - Replacement for the data row if found.
* * `null` - Flag to delete the data row if found. The found data row is nonetheless returned.
* * `undefined` - Flag to return index of found row instead of row object itself.
* @returns {object|number|undefined} One of:
* * `undefined` - data row not found
* * _object_ - found data row object (will have been deleted if `replacement` was `null`)
* * _number_ - index of found data row object in `this.data` (if `replacement` was `undefined`)
* @todo Implement binary search when the column is currently indexed (sorted).
*/
findRow: function findRow(columnName, value, replacement) {
var result, index, keys, hash,
lastArgIndex = findRow.length;
if (typeof columnName === 'object') {
hash = columnName;
if (value instanceof Array) {
keys = value;
if (keys.reduce(function(sum, key) {
if (key in hash) { sum++; }
return sum;
}, 0) !== keys.length) {
throw 'Expected all keys given in 2nd arg to be found in hash given in 1st arg.';
}
} else {
keys = Object.keys(hash);
lastArgIndex--;
replacement = value; // promote
}
if (keys.length === 1) {
columnName = keys[0];
value = hash[columnName];
hash = undefined;
} else if (keys.length) {
result = this.data.find(function(row, idx) {
index = idx;
for (var key in keys) {
columnName = keys[key];
if (row[columnName] !== hash[columnName]) {
return; // bail
}
}
return true; // found!
});
}
}
if (!hash) {
result = this.data.find(function(row, idx) {
index = idx;
return row[columnName] === value;
});
}
if (result) {
if (typeof replacement === 'object') {
if (replacement === null) {
this.data.splice(index, 1);
} else {
this.data[index] = replacement;
}
} else if (replacement === undefined) {
if (arguments.length >= 3) { // explicit undefined was passed
result = index;
}
} else {
throw 'Expected null, undefined, or object but found ' + typeof replacement + '.';
}
}
return result;

@@ -48,0 +125,0 @@ },

3

js/DataSourceTreeview.js

@@ -33,4 +33,3 @@ 'use strict';

setRelation: function(options) {
var idColumn, parentIdColumn,
r, parentID, depth, leafRow, row, ID;
var r, parentID, depth, leafRow, row, ID;

@@ -37,0 +36,0 @@ // successful join requires that options object be given and that all three columns exist

{
"name": "hyper-analytics",
"version": "0.11.7",
"version": "0.11.8",
"description": "Data transformations on arrays of congruent JavaScript objects.",

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

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