Comparing version 2.3.0 to 2.4.0
@@ -96,2 +96,8 @@ import {Suite} from 'benchmark' | ||
}) | ||
.add('Dodo #filterBy #col #length', () => { | ||
dodo | ||
.filterBy('NumberOfDependents', n => n == 2) | ||
.col('NumberOfDependents') | ||
.length | ||
}) | ||
.add('Dodo #col() #mean()', () => { | ||
@@ -98,0 +104,0 @@ dodo |
{ | ||
"name": "dodos", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"description": "Pandas-inspired iterator-based data wrangling library for js", | ||
@@ -28,3 +28,3 @@ "main": "dist/dodos.js", | ||
"babel-core": "~6.7.2", | ||
"babel-eslint": "~5.0.0", | ||
"babel-eslint": "~6.0.0", | ||
"babel-loader": "~6.2.4", | ||
@@ -36,3 +36,3 @@ "babel-polyfill": "~6.7.2", | ||
"d3-dsv": "~0.3.1", | ||
"eslint": "~2.5.0", | ||
"eslint": "~2.5.1", | ||
"husky": "~0.11.4", | ||
@@ -39,0 +39,0 @@ "npm-check": "~4.1.4", |
@@ -7,1 +7,25 @@ # Dodos | ||
NOTE: This is very much a work in progress for now | ||
```js | ||
array = [ | ||
[1, 2, 3], | ||
[3, 4, 5], | ||
] | ||
index = ['columnA', 'columnB', 'columnC'] | ||
const dodo = new Dodo(array, index) | ||
dodo.col('columnA').toArray() // [1, 3] | ||
dodo.filterBy('columnB', b => b == 4).toArray() // [4] | ||
dodo.col('columnA').sum() // 4 | ||
``` | ||
All methods return a new instance, leaving the original untouched. | ||
All operations on the array are evaluated only when calling `.toArray()` or when calling a `.reduce()` method (eg. `.sum()`). | ||
For now, please refer to the tests for more usage examples. |
@@ -66,2 +66,4 @@ import invariant from 'invariant' | ||
get length() { return this.toArray().length } | ||
uniq() { return [...new Set(this)] } | ||
@@ -68,0 +70,0 @@ |
@@ -264,2 +264,11 @@ import test from 'ava' | ||
test('length', t => { | ||
const dodo = new Dodo(table, index) | ||
t.ok(dodo.col('Age').toArray().length == dodo.length) | ||
t.ok(dodo.cols('Age', 'Date').toArray().length | ||
== dodo.cols('Age', 'Date').length) | ||
t.ok(dodo.filterBy('Height', h => h >= 7).toArray().length | ||
== dodo.filterBy('Height', h => h >= 7).length) | ||
}) | ||
test('reduce of single column', t => { | ||
@@ -266,0 +275,0 @@ const dodo = new Dodo(table, index) |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7868452
4207
31