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

array-table-search

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-table-search - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

4

CHANGELOG.md

@@ -0,1 +1,5 @@

1.0.2 - September, 07 2018
* 517132a Fix: babel runtime (#2) (Lukas Aichbauer)
1.0.1 - May, 06 2018

@@ -2,0 +6,0 @@

22

lib/index.js

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,9 +6,17 @@ Object.defineProperty(exports, "__esModule", {

});
exports.multiColumnSearchArrayTable = exports.searchArrayTable = undefined;
Object.defineProperty(exports, "searchArrayTable", {
enumerable: true,
get: function get() {
return _searchArrayTable.searchArrayTable;
}
});
Object.defineProperty(exports, "multiColumnSearchArrayTable", {
enumerable: true,
get: function get() {
return _multiColumnSearchArrayTable.multiColumnSearchArrayTable;
}
});
var _searchArrayTable = require('./modules/search-array-table');
var _searchArrayTable = require("./modules/search-array-table");
var _multiColumnSearchArrayTable = require('./modules/multi-column-search-array-table');
exports.searchArrayTable = _searchArrayTable.searchArrayTable;
exports.multiColumnSearchArrayTable = _multiColumnSearchArrayTable.multiColumnSearchArrayTable;
var _multiColumnSearchArrayTable = require("./modules/multi-column-search-array-table");

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,23 +6,19 @@ Object.defineProperty(exports, "__esModule", {

});
exports.multiColumnSearchArrayTable = undefined;
exports.multiColumnSearchArrayTable = void 0;
var _entries = require('babel-runtime/core-js/object/entries');
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
var _entries2 = _interopRequireDefault(_entries);
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var _typeof2 = require('babel-runtime/helpers/typeof');
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var _typeof3 = _interopRequireDefault(_typeof2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var checkIfValid = function checkIfValid(data) {
if (!Array.isArray(data)) {
throw new Error('data has to be typeof: ' + (0, _typeof3.default)([]) + ' data instanceof Array: ' + ([] instanceof Array) + ' but got typeof: ' + (typeof data === 'undefined' ? 'undefined' : (0, _typeof3.default)(data)) + ' data instanceof Array: ' + (data instanceof Array));
} else if (Array.isArray(data) && data.length > 0 && (0, _typeof3.default)(data[0]) !== 'object') {
throw new Error('data has to be an array of objects but data[0] got typeof: ' + (0, _typeof3.default)(data[0]));
throw new Error("data has to be typeof: ".concat(_typeof([]), " data instanceof Array: ").concat([] instanceof Array, " but got typeof: ").concat(_typeof(data), " data instanceof Array: ").concat(data instanceof Array));
} else if (Array.isArray(data) && data.length > 0 && _typeof(data[0]) !== 'object') {
throw new Error("data has to be an array of objects but data[0] got typeof: ".concat(_typeof(data[0])));
}

@@ -32,12 +28,12 @@ };

var createTableCheck = function createTableCheck(data, options, tableCheck) {
var table = [].concat((0, _toConsumableArray3.default)(tableCheck));
var table = _toConsumableArray(tableCheck);
options.forEach(function (valueEntry) {
var currentValue = valueEntry[1].value.toString().toLowerCase();
var currentItem = valueEntry[0];
options.forEach(function (searchEntry, idx) {
var currentSearch = searchEntry[1].type;
data.forEach(function (item, i) {
var currentItemValue = item[searchEntry[0]] ? item[searchEntry[0]].toString().toLowerCase() : '';
if (currentItem === searchEntry[0]) {

@@ -53,3 +49,5 @@ switch (currentSearch) {

}
break;
case 'includes':

@@ -64,2 +62,3 @@ default:

}
break;

@@ -71,19 +70,17 @@ }

});
return table;
};
var multiColumnSearchArrayTable = exports.multiColumnSearchArrayTable = function multiColumnSearchArrayTable(data, options) {
var multiColumnSearchArrayTable = function multiColumnSearchArrayTable(data, options) {
checkIfValid(data);
var opts = (0, _entries2.default)(options).filter(function (entry) {
return (0, _typeof3.default)(entry[1]) === 'object' && (entry[1].value || entry[1].value === '');
var opts = [];
Object.keys(options).forEach(function (key) {
var arr = [];
arr.push(key.toString(), options[key]);
opts.push(arr);
});
var emptyTable = data.map(function () {
return [];
});
var checkedTable = createTableCheck(data, opts, emptyTable);
var searchedData = data.filter(function (dataItem, idx) {

@@ -94,4 +91,5 @@ return checkedTable[idx].every(function (item) {

});
return searchedData;
};
return searchedData;
};
exports.multiColumnSearchArrayTable = multiColumnSearchArrayTable;

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,25 +6,16 @@ Object.defineProperty(exports, "__esModule", {

});
exports.searchArrayTable = undefined;
exports.searchArrayTable = void 0;
var _values = require('babel-runtime/core-js/object/values');
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var _values2 = _interopRequireDefault(_values);
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var checkIfValid = function checkIfValid(data) {
if (!Array.isArray(data)) {
throw new Error('data has to be typeof: ' + (0, _typeof3.default)([]) + ' data instanceof Array: ' + ([] instanceof Array) + ' but got typeof: ' + (typeof data === 'undefined' ? 'undefined' : (0, _typeof3.default)(data)) + ' data instanceof Array: ' + (data instanceof Array));
} else if (Array.isArray(data) && data.length > 0 && (0, _typeof3.default)(data[0]) !== 'object') {
throw new Error('data has to be an array of objects but data[0] got typeof: ' + (0, _typeof3.default)(data[0]));
throw new Error("data has to be typeof: ".concat(_typeof([]), " data instanceof Array: ").concat([] instanceof Array, " but got typeof: ").concat(_typeof(data), " data instanceof Array: ").concat(data instanceof Array));
} else if (Array.isArray(data) && data.length > 0 && _typeof(data[0]) !== 'object') {
throw new Error("data has to be an array of objects but data[0] got typeof: ".concat(_typeof(data[0])));
}
};
var searchArrayTable = exports.searchArrayTable = function searchArrayTable(data, options) {
var searchArrayTable = function searchArrayTable(data, options) {
checkIfValid(data);
var searchedData = [];

@@ -34,7 +25,5 @@

var searchValue = options.value.toString().toLowerCase();
data.forEach(function (item) {
var currentItemValues = (0, _values2.default)(item).map(function (val) {
var result = val ? val.toString().toLowerCase() : '';
var currentItemValues = Object.keys(item).map(function (key) {
var result = item[key] ? item[key].toString().toLowerCase() : '';
return result;

@@ -53,4 +42,6 @@ });

}
break;
}
case 'includes':

@@ -66,2 +57,3 @@ default:

}
break;

@@ -76,2 +68,4 @@ }

return searchedData;
};
};
exports.searchArrayTable = searchArrayTable;
{
"name": "array-table-search",
"version": "1.0.1",
"version": "1.0.2",
"description": "Search on an array that are that holds data for tables",

@@ -11,7 +11,8 @@ "main": "./lib/index.js",

"scripts": {
"pretest": "npm run build && npm run lint",
"pretest": "yarn run build && yarn run lint",
"lint": "eslint src",
"test": "jest --coverage",
"build": "babel src --out-dir lib",
"prepublish": "npm run build"
"prepush": "yarn run test",
"prepublish": "yarn run build"
},

@@ -38,11 +39,14 @@ "keywords": [

"devDependencies": {
"babel-cli": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-preset-es2017": "^6.24.1",
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.9.0",
"jest": "^22.4.3"
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"babel-core": "^7.0.0-0",
"babel-jest": "^23.4.2",
"eslint": "^5.5.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.14.0",
"husky": "^0.14.3",
"jest": "^23.5.0",
"regenerator-runtime": "^0.12.1"
}
}
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