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

@tidyjs/tidy

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tidyjs/tidy - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

74

dist/es/helpers/summation.js

@@ -1,69 +0,19 @@

function sum(items, accessor) {
let sum2 = 0, correction = 0, temp = 0;
for (let i = 0; i < items.length; i++) {
let value = accessor === void 0 ? items[i] : accessor(items[i], i, items);
if (+value !== value) {
value = 0;
}
if (i === 0) {
sum2 = value;
} else {
temp = sum2 + value;
if (Math.abs(sum2) >= Math.abs(value)) {
correction += sum2 - temp + value;
} else {
correction += value - temp + sum2;
}
sum2 = temp;
}
}
return sum2 + correction;
import { Adder, fsum } from 'd3-array';
function fcumsum(items, accessor) {
let sum = new Adder(), i = 0;
return Float64Array.from(items, (value) => sum.add(+(accessor(value, i++, items) || 0)));
}
function cumsum(items, accessor) {
let sum2 = 0, correction = 0, temp = 0, cumsums = new Float64Array(items.length);
for (let i = 0; i < items.length; i++) {
let value = accessor === void 0 ? items[i] : accessor(items[i], i, items);
if (+value !== value) {
value = 0;
}
if (i === 0) {
sum2 = value;
} else {
temp = sum2 + value;
if (Math.abs(sum2) >= Math.abs(value)) {
correction += sum2 - temp + value;
} else {
correction += value - temp + sum2;
}
sum2 = temp;
}
cumsums[i] = sum2 + correction;
}
return cumsums;
}
function mean(items, accessor) {
let n = 0, sum2 = 0, correction = 0, temp = 0;
for (let i = 0; i < items.length; i++) {
let value = accessor === void 0 ? items[i] : accessor(items[i], i, items);
if (+value !== value) {
value = 0;
} else {
n++;
let n = 0;
for (let i = 0; i < items.length; ++i) {
const value = accessor(items[i], i, items);
if (+value === value) {
n += 1;
}
if (i === 0) {
sum2 = value;
} else {
temp = sum2 + value;
if (Math.abs(sum2) >= Math.abs(value)) {
correction += sum2 - temp + value;
} else {
correction += value - temp + sum2;
}
sum2 = temp;
}
}
return n ? (sum2 + correction) / n : void 0;
return n ? fsum(items, accessor) / n : void 0;
}
export { cumsum, mean, sum };
export { fcumsum, mean };
//# sourceMappingURL=summation.js.map

4

dist/es/select.js

@@ -13,3 +13,3 @@ import { singleOrArray } from './helpers/singleOrArray.js';

}
if (processedSelectKeys[0][0] === "-") {
if (processedSelectKeys.length && processedSelectKeys[0][0] === "-") {
processedSelectKeys = [...everything()(items), ...processedSelectKeys];

@@ -37,2 +37,4 @@ }

let processedSelectKeys = processSelectors(items, selectKeys);
if (!processedSelectKeys.length)
return items;
return items.map((d) => {

@@ -39,0 +41,0 @@ const mapped = {};

@@ -0,3 +1,3 @@

import { fsum } from 'd3-array';
import { rate } from '../math/math.js';
import { sum } from '../helpers/summation.js';

@@ -8,4 +8,4 @@ function meanRate(numerator, denominator) {

return (items) => {
const numerator2 = sum(items, numeratorFn);
const denominator2 = sum(items, denominatorFn);
const numerator2 = fsum(items, numeratorFn);
const denominator2 = fsum(items, denominatorFn);
return rate(numerator2, denominator2);

@@ -12,0 +12,0 @@ };

@@ -1,6 +0,6 @@

import { sum as sum$1 } from '../helpers/summation.js';
import { fsum } from 'd3-array';
function sum(key) {
const keyFn = typeof key === "function" ? key : (d) => d[key];
return (items) => sum$1(items, keyFn);
return (items) => fsum(items, keyFn);
}

@@ -7,0 +7,0 @@

@@ -1,6 +0,6 @@

import { cumsum as cumsum$1 } from '../helpers/summation.js';
import { fcumsum } from '../helpers/summation.js';
function cumsum(key) {
const keyFn = typeof key === "function" ? key : (d) => d[key];
return (items) => cumsum$1(items, keyFn);
return (items) => fcumsum(items, keyFn);
}

@@ -7,0 +7,0 @@

@@ -5,72 +5,21 @@ 'use strict';

function sum(items, accessor) {
let sum2 = 0, correction = 0, temp = 0;
for (let i = 0; i < items.length; i++) {
let value = accessor === void 0 ? items[i] : accessor(items[i], i, items);
if (+value !== value) {
value = 0;
}
if (i === 0) {
sum2 = value;
} else {
temp = sum2 + value;
if (Math.abs(sum2) >= Math.abs(value)) {
correction += sum2 - temp + value;
} else {
correction += value - temp + sum2;
}
sum2 = temp;
}
}
return sum2 + correction;
var d3Array = require('d3-array');
function fcumsum(items, accessor) {
let sum = new d3Array.Adder(), i = 0;
return Float64Array.from(items, (value) => sum.add(+(accessor(value, i++, items) || 0)));
}
function cumsum(items, accessor) {
let sum2 = 0, correction = 0, temp = 0, cumsums = new Float64Array(items.length);
for (let i = 0; i < items.length; i++) {
let value = accessor === void 0 ? items[i] : accessor(items[i], i, items);
if (+value !== value) {
value = 0;
}
if (i === 0) {
sum2 = value;
} else {
temp = sum2 + value;
if (Math.abs(sum2) >= Math.abs(value)) {
correction += sum2 - temp + value;
} else {
correction += value - temp + sum2;
}
sum2 = temp;
}
cumsums[i] = sum2 + correction;
}
return cumsums;
}
function mean(items, accessor) {
let n = 0, sum2 = 0, correction = 0, temp = 0;
for (let i = 0; i < items.length; i++) {
let value = accessor === void 0 ? items[i] : accessor(items[i], i, items);
if (+value !== value) {
value = 0;
} else {
n++;
let n = 0;
for (let i = 0; i < items.length; ++i) {
const value = accessor(items[i], i, items);
if (+value === value) {
n += 1;
}
if (i === 0) {
sum2 = value;
} else {
temp = sum2 + value;
if (Math.abs(sum2) >= Math.abs(value)) {
correction += sum2 - temp + value;
} else {
correction += value - temp + sum2;
}
sum2 = temp;
}
}
return n ? (sum2 + correction) / n : void 0;
return n ? d3Array.fsum(items, accessor) / n : void 0;
}
exports.cumsum = cumsum;
exports.fcumsum = fcumsum;
exports.mean = mean;
exports.sum = sum;
//# sourceMappingURL=summation.js.map

@@ -17,3 +17,3 @@ 'use strict';

}
if (processedSelectKeys[0][0] === "-") {
if (processedSelectKeys.length && processedSelectKeys[0][0] === "-") {
processedSelectKeys = [...everything.everything()(items), ...processedSelectKeys];

@@ -41,2 +41,4 @@ }

let processedSelectKeys = processSelectors(items, selectKeys);
if (!processedSelectKeys.length)
return items;
return items.map((d) => {

@@ -43,0 +45,0 @@ const mapped = {};

@@ -5,4 +5,4 @@ 'use strict';

var d3Array = require('d3-array');
var math = require('../math/math.js');
var summation = require('../helpers/summation.js');

@@ -13,4 +13,4 @@ function meanRate(numerator, denominator) {

return (items) => {
const numerator2 = summation.sum(items, numeratorFn);
const denominator2 = summation.sum(items, denominatorFn);
const numerator2 = d3Array.fsum(items, numeratorFn);
const denominator2 = d3Array.fsum(items, denominatorFn);
return math.rate(numerator2, denominator2);

@@ -17,0 +17,0 @@ };

@@ -5,7 +5,7 @@ 'use strict';

var summation = require('../helpers/summation.js');
var d3Array = require('d3-array');
function sum(key) {
const keyFn = typeof key === "function" ? key : (d) => d[key];
return (items) => summation.sum(items, keyFn);
return (items) => d3Array.fsum(items, keyFn);
}

@@ -12,0 +12,0 @@

@@ -9,3 +9,3 @@ 'use strict';

const keyFn = typeof key === "function" ? key : (d) => d[key];
return (items) => summation.cumsum(items, keyFn);
return (items) => summation.fcumsum(items, keyFn);
}

@@ -12,0 +12,0 @@

@@ -510,72 +510,5 @@ (function (global, factory) {

function sum(items, accessor) {
let sum2 = 0, correction = 0, temp = 0;
for (let i = 0; i < items.length; i++) {
let value = accessor === void 0 ? items[i] : accessor(items[i], i, items);
if (+value !== value) {
value = 0;
}
if (i === 0) {
sum2 = value;
} else {
temp = sum2 + value;
if (Math.abs(sum2) >= Math.abs(value)) {
correction += sum2 - temp + value;
} else {
correction += value - temp + sum2;
}
sum2 = temp;
}
}
return sum2 + correction;
}
function cumsum(items, accessor) {
let sum2 = 0, correction = 0, temp = 0, cumsums = new Float64Array(items.length);
for (let i = 0; i < items.length; i++) {
let value = accessor === void 0 ? items[i] : accessor(items[i], i, items);
if (+value !== value) {
value = 0;
}
if (i === 0) {
sum2 = value;
} else {
temp = sum2 + value;
if (Math.abs(sum2) >= Math.abs(value)) {
correction += sum2 - temp + value;
} else {
correction += value - temp + sum2;
}
sum2 = temp;
}
cumsums[i] = sum2 + correction;
}
return cumsums;
}
function mean(items, accessor) {
let n = 0, sum2 = 0, correction = 0, temp = 0;
for (let i = 0; i < items.length; i++) {
let value = accessor === void 0 ? items[i] : accessor(items[i], i, items);
if (+value !== value) {
value = 0;
} else {
n++;
}
if (i === 0) {
sum2 = value;
} else {
temp = sum2 + value;
if (Math.abs(sum2) >= Math.abs(value)) {
correction += sum2 - temp + value;
} else {
correction += value - temp + sum2;
}
sum2 = temp;
}
}
return n ? (sum2 + correction) / n : void 0;
}
function sum$1(key) {
function sum(key) {
const keyFn = typeof key === "function" ? key : (d) => d[key];
return (items) => sum(items, keyFn);
return (items) => d3Array.fsum(items, keyFn);
}

@@ -586,3 +519,3 @@

const {name = "n", wt} = options != null ? options : {};
const summarized = summarize({[name]: wt == null ? n() : sum$1(wt)})(items);
const summarized = summarize({[name]: wt == null ? n() : sum(wt)})(items);
return summarized;

@@ -749,3 +682,3 @@ };

}
if (processedSelectKeys[0][0] === "-") {
if (processedSelectKeys.length && processedSelectKeys[0][0] === "-") {
processedSelectKeys = [...everything()(items), ...processedSelectKeys];

@@ -773,2 +706,4 @@ }

let processedSelectKeys = processSelectors(items, selectKeys);
if (!processedSelectKeys.length)
return items;
return items.map((d) => {

@@ -1123,5 +1058,20 @@ const mapped = {};

function cumsum$1(key) {
function fcumsum(items, accessor) {
let sum = new d3Array.Adder(), i = 0;
return Float64Array.from(items, (value) => sum.add(+(accessor(value, i++, items) || 0)));
}
function mean(items, accessor) {
let n = 0;
for (let i = 0; i < items.length; ++i) {
const value = accessor(items[i], i, items);
if (+value === value) {
n += 1;
}
}
return n ? d3Array.fsum(items, accessor) / n : void 0;
}
function cumsum(key) {
const keyFn = typeof key === "function" ? key : (d) => d[key];
return (items) => cumsum(items, keyFn);
return (items) => fcumsum(items, keyFn);
}

@@ -1163,4 +1113,4 @@

return (items) => {
const numerator2 = sum(items, numeratorFn);
const denominator2 = sum(items, denominatorFn);
const numerator2 = d3Array.fsum(items, numeratorFn);
const denominator2 = d3Array.fsum(items, denominatorFn);
return rate(numerator2, denominator2);

@@ -1264,3 +1214,3 @@ };

exports.count = count;
exports.cumsum = cumsum$1;
exports.cumsum = cumsum;
exports.debug = debug;

@@ -1312,3 +1262,3 @@ exports.desc = desc;

exports.startsWith = startsWith;
exports.sum = sum$1;
exports.sum = sum;
exports.summarize = summarize;

@@ -1315,0 +1265,0 @@ exports.summarizeAll = summarizeAll;

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

(function(l,v){typeof exports=="object"&&typeof module!="undefined"?v(exports,require("d3-array")):typeof define=="function"&&define.amd?define(["exports","d3-array"],v):(l=typeof globalThis!="undefined"?globalThis:l||self,v(l.Tidy={},l.d3))})(this,function(l,v){"use strict";function $(n,...t){if(typeof n=="function")throw new Error("You must supply the data as the first argument to tidy()");let e=n;for(const u of t)e=u(e);return e}function cn(n){return e=>e.filter(n)}function sn(n,t){return u=>{if(typeof n=="function"){if(!n(u))return u}else if(!n)return u;return $(u,...t)}}function ln(n){return e=>e.map(n)}function S(n){return n==null?[]:Array.isArray(n)?n:[n]}function an(n){return e=>{if(n=S(n),!n.length){const r=new Set;for(const s of e)r.add(s);return Array.from(r)}const u=new Map,o=[],c=n[n.length-1];for(const r of e){let s=u,a=!1;for(const f of n){const d=typeof f=="function"?f(r):r[f];if(f===c){a=s.has(d),a||(o.push(r),s.set(d,!0));break}s.has(d)||s.set(d,new Map),s=s.get(d)}}return o}}function I(n){return e=>{const u=S(n).map(o=>typeof o=="function"?o:U(o));return e.slice().sort((o,c)=>{for(const r of u){const s=r(o,c);if(s!==0)return s}return 0})}}function U(n){return function(e,u){return v.ascending(e[n],u[n])}}function B(n){return function(e,u){return v.descending(e[n],u[n])}}function fn(n,t,e){let{position:u="start"}=e!=null?e:{};const o=u==="end"?-1:1,c=new Map;for(let s=0;s<t.length;++s)c.set(t[s],s);const r=typeof n=="function"?n:s=>s[n];return function(a,f){var d,i;const m=(d=c.get(r(a)))!=null?d:-1,y=(i=c.get(r(f)))!=null?i:-1;return m>=0&&y>=0?m-y:m>=0?o*-1:y>=0?o*1:0}}function D(n,t){return u=>{t=t!=null?t:{};const o={},c=Object.keys(n);for(const r of c)o[r]=n[r](u);if(t.rest&&u.length){const r=Object.keys(u[0]);for(const s of r)c.includes(s)||(o[s]=t.rest(s)(u))}return[o]}}function R(n,t,e,u){if(!n.length)return[];const o={};let c;if(u==null)c=Object.keys(n[0]);else{c=[];for(const r of S(u))typeof r=="function"?c.push(...r(n)):c.push(r)}for(const r of c){if(e){const s=n.map(a=>a[r]);if(!e(s))continue}o[r]=t(r)(n)}return[o]}function N(n){return e=>R(e,n)}function J(n,t){return u=>R(u,t,n)}function H(n,t){return u=>R(u,t,void 0,n)}function k(n){return e=>{const u=[];for(const o of e){const c={...o};for(const r in n){const s=n[r],a=typeof s=="function"?s(c):s;c[r]=a}u.push(c)}return u}}function mn(n,t){return u=>{const o=D(n)(u),c=k(t)(o);return[...u,...c]}}function dn(n,t){return u=>{const o=N(n)(u),c=k(t)(o);return[...u,...c]}}function yn(n,t,e){return o=>{const c=J(n,t)(o),r=k(e)(c);return[...o,...r]}}function pn(n,t,e){return o=>{const c=H(n,t)(o),r=k(e)(c);return[...o,...r]}}function z(n,t){return{...n,...t.reduce((e,u)=>(e[u[0]]=u[1],e),{})}}function L(n,t,e,u,o,c=0){for(const[r,s]of n.entries()){const a=[...e,r];if(s instanceof Map){const f=u(t,a,c);L(s,f,a,u,o,c+1)}else o(t,a,s,c)}return t}function hn(n,t,e=u=>u[u.length-1]){function u(r,s){const a=new Map;return r.set(e(s),a),a}function o(r,s,a){r.set(e(s),t(a,s))}const c=new Map;return L(n,c,[],u,o),c}const O=n=>n;function _(n,t,e){return o=>{const c=vn(o,n),r=gn(c,t,e==null?void 0:e.addGroupKeys);if(e==null?void 0:e.export)switch(e.export){case"grouped":return r;case"entries":return j(r,{...e,export:"levels",levels:["entries"]});case"entries-object":case"entries-obj":case"entriesObject":return j(r,{...e,export:"levels",levels:["entries-object"]});case"object":return j(r,{...e,export:"levels",levels:["object"]});case"map":return j(r,{...e,export:"levels",levels:["map"]});case"keys":return j(r,{...e,export:"levels",levels:["keys"]});case"values":return j(r,{...e,export:"levels",levels:["values"]});case"levels":return j(r,e)}return _n(r,e==null?void 0:e.addGroupKeys)}}_.grouped=n=>({...n,export:"grouped"}),_.entries=n=>({...n,export:"entries"}),_.entriesObject=n=>({...n,export:"entries-object"}),_.object=n=>({...n,export:"object"}),_.map=n=>({...n,export:"map"}),_.keys=n=>({...n,export:"keys"}),_.values=n=>({...n,export:"values"}),_.levels=n=>({...n,export:"levels"});function gn(n,t,e){let u=n;if(!(t==null?void 0:t.length))return u;for(const o of t)u=hn(u,(c,r)=>{let a=o(c,{groupKeys:r});return e!==!1&&(a=a.map(f=>z(f,r))),a});return u}function vn(n,t){const e=S(t).map((o,c)=>{let r;typeof o=="function"?r=o.name?o.name:`group_${c}`:r=o.toString();const s=typeof o=="function"?o:f=>f[o],a=new Map;return f=>{const d=s(f);if(a.has(d))return a.get(d);const i=[r,d];return a.set(d,i),i}});return v.group(n,...e)}function _n(n,t){const e=[];return L(n,e,[],O,(u,o,c)=>{let r=c;t!==!1&&(r=c.map(s=>z(s,o))),u.push(...r)}),e}const bn=n=>n.join("/");function Sn(n){var t;const{flat:e,single:u,mapLeaf:o=O,mapLeaves:c=O}=n;let r;return n.flat&&(r=(t=n.compositeKey)!=null?t:bn),{groupFn:(f,d)=>u?o(z(f[0],d)):c(f.map(i=>o(z(i,d)))),keyFn:e?f=>r(f.map(d=>d[1])):f=>f[f.length-1][1]}}function j(n,t){const{groupFn:e,keyFn:u}=Sn(t);let{mapEntry:o=O}=t;const{levels:c=["entries"]}=t,r=[];for(const d of c)switch(d){case"entries":case"entries-object":case"entries-obj":case"entriesObject":{const i=d==="entries-object"||d==="entries-obj"||d==="entriesObject"?([m,y])=>({key:m,values:y}):o;r.push({id:"entries",createEmptySubgroup:()=>[],addSubgroup:(m,y,h,b)=>{m.push(i([h,y],b))},addLeaf:(m,y,h,b)=>{m.push(i([y,h],b))}});break}case"map":r.push({id:"map",createEmptySubgroup:()=>new Map,addSubgroup:(i,m,y)=>{i.set(y,m)},addLeaf:(i,m,y)=>{i.set(m,y)}});break;case"object":r.push({id:"object",createEmptySubgroup:()=>({}),addSubgroup:(i,m,y)=>{i[y]=m},addLeaf:(i,m,y)=>{i[m]=y}});break;case"keys":r.push({id:"keys",createEmptySubgroup:()=>[],addSubgroup:(i,m,y)=>{i.push([y,m])},addLeaf:(i,m)=>{i.push(m)}});break;case"values":r.push({id:"values",createEmptySubgroup:()=>[],addSubgroup:(i,m)=>{i.push(m)},addLeaf:(i,m,y)=>{i.push(y)}});break;default:typeof d=="object"&&r.push(d)}const s=(d,i,m)=>{var y,h;if(t.flat)return d;const b=(y=r[m])!=null?y:r[r.length-1],A=((h=r[m+1])!=null?h:b).createEmptySubgroup();return b.addSubgroup(d,A,u(i),m),A},a=(d,i,m,y)=>{var h;((h=r[y])!=null?h:r[r.length-1]).addLeaf(d,u(i),e(m,i),y)},f=r[0].createEmptySubgroup();return L(n,f,[],s,a)}function P(){return n=>n.length}function W(n,t){let e=0,u=0,o=0;for(let c=0;c<n.length;c++){let r=t===void 0?n[c]:t(n[c],c,n);+r!==r&&(r=0),c===0?e=r:(o=e+r,Math.abs(e)>=Math.abs(r)?u+=e-o+r:u+=r-o+e,e=o)}return e+u}function Mn(n,t){let e=0,u=0,o=0,c=new Float64Array(n.length);for(let r=0;r<n.length;r++){let s=t===void 0?n[r]:t(n[r],r,n);+s!==s&&(s=0),r===0?e=s:(o=e+s,Math.abs(e)>=Math.abs(s)?u+=e-o+s:u+=s-o+e,e=o),c[r]=e+u}return c}function jn(n,t){let e=0,u=0,o=0,c=0;for(let r=0;r<n.length;r++){let s=t===void 0?n[r]:t(n[r],r,n);+s!==s?s=0:e++,r===0?u=s:(c=u+s,Math.abs(u)>=Math.abs(s)?o+=u-c+s:o+=s-c+u,u=c)}return e?(u+o)/e:void 0}function G(n){const t=typeof n=="function"?n:e=>e[n];return e=>W(e,t)}function Y(n){return e=>{const{name:u="n",wt:o}=n!=null?n:{};return D({[u]:o==null?P():G(o)})(e)}}function kn(n,t){return u=>{t=t!=null?t:{};const{name:o="n",sort:c}=t;return $(u,_(n,[Y(t)]),c?I(B(o)):O)}}function wn(n){return e=>e.map(u=>{var o;const c={},r=Object.keys(u);for(const s of r){const a=(o=n[s])!=null?o:s;c[a]=u[s]}return c})}function E(n,t){return u=>u.slice(n,t)}const Kn=n=>E(0,n),Fn=n=>E(-n);function In(n,t){return u=>I(t)(u).slice(0,n)}function On(n,t){return u=>I(t)(u).slice(-n).reverse()}function An(n,t){t=t!=null?t:{};const{replace:e}=t;return o=>{if(!o.length)return o.slice();if(e){const c=[];for(let r=0;r<n;++r)c.push(o[Math.floor(Math.random()*o.length)]);return c}return v.shuffle(o.slice()).slice(0,n)}}function Z(n,t){if(n.length===0||t.length===0)return{};const e=Object.keys(n[0]),u=Object.keys(t[0]),o={};for(const c of e)u.includes(c)&&(o[c]=c);return o}function Q(n){if(Array.isArray(n)){const t={};for(const e of n)t[e]=e;return t}else if(typeof n=="object")return n;return{[n]:n}}function X(n,t,e){for(const u in e){const o=e[u];if(n[o]!==t[u])return!1}return!0}function $n(n,t){return u=>{const o=(t==null?void 0:t.by)==null?Z(u,n):Q(t.by);return u.flatMap(r=>n.filter(a=>X(r,a,o)).map(a=>({...r,...a})))}}function x(n,t){return u=>{const o=(t==null?void 0:t.by)==null?Z(u,n):Q(t.by);return u.flatMap(r=>{const s=n.filter(a=>X(r,a,o));return s.length?s.map(a=>({...r,...a})):r})}}function zn(n){return e=>{const u=e.map(o=>({...o}));for(const o in n){const c=n[o],r=typeof c=="function"?c(u):c,s=(r==null?void 0:r[Symbol.iterator])&&typeof r!="string"?r:e.map(()=>r);let a=-1;for(const f of u)f[o]=s[++a]}return u}}function w(n){return n.length<1?[]:Object.keys(n[0])}function nn(){return n=>w(n)}function en(n,t){let e=[];for(const c of S(t))typeof c=="function"?e.push(...c(n)):e.push(c);e[0][0]==="-"&&(e=[...nn()(n),...e]);const u={},o=[];for(let c=e.length-1;c>=0;c--){const r=e[c];if(r[0]==="-"){u[r.substring(1)]=!0;continue}if(u[r]){u[r]=!1;continue}o.unshift(r)}return e=Array.from(new Set(o)),e}function C(n){return e=>{let u=en(e,n);return e.map(o=>{const c={};for(const r of u)c[r]=o[r];return c})}}function Ln(n){return e=>{const u=k(n)(e);return C(Object.keys(n))(u)}}function tn(n){return e=>typeof n=="function"?[...e,...S(n(e))]:[...e,...S(n)]}function Tn(n){return e=>{const{namesFrom:u,valuesFrom:o,valuesFill:c,valuesFillMap:r,namesSep:s="_"}=n,a=Array.isArray(u)?u:[u],f=Array.isArray(o)?o:[o],d=[];if(!e.length)return d;const i=Object.keys(e[0]).filter(p=>!a.includes(p)&&!f.includes(p)),m={};for(const p of e)for(const g of a)m[g]==null&&(m[g]={}),m[g][p[g]]=!0;const y=[];for(const p in m)y.push(Object.keys(m[p]));const h={},b=qn(s,y);for(const p of b){if(f.length===1){h[p]=r!=null?r[f[0]]:c;continue}for(const g of f)h[`${g}${s}${p}`]=r!=null?r[g]:c}function K(p){if(!p.length)return[];const g={...h};for(const M of i)g[M]=p[0][M];for(const M of p){const q=a.map(F=>M[F]).join(s);if(f.length===1){g[q]=M[f[0]];continue}for(const F of f)g[`${F}${s}${q}`]=M[F]}return[g]}return i.length?$(e,_(i,[K])):K(e)}}function qn(n="_",t){function e(o,c,r){if(!r.length&&c!=null){o.push(c);return}const s=r[0],a=r.slice(1);for(const f of s)e(o,c==null?f:`${c}${n}${f}`,a)}const u=[];return e(u,null,t),u}function Dn(n){return e=>{var u;const{namesTo:o,valuesTo:c,namesSep:r="_"}=n,s=(u=n.cols)!=null?u:[],a=en(e,s),f=Array.isArray(o)?o:[o],d=Array.isArray(c)?c:[c],i=f.length>1,m=d.length>1,y=[];for(const h of e){const b=Object.keys(h).filter(p=>!a.includes(p)),K={};for(const p of b)K[p]=h[p];const A=m?Array.from(new Set(a.map(p=>p.substring(p.indexOf(r)+1)))):a;for(const p of A){const g={...K};for(const M of d){const q=m?`${M}${r}${p}`:p,F=i?p.split(r):[p];let fe=0;for(const ie of f){const me=F[fe++];g[ie]=me,g[M]=h[q]}}y.push(g)}}return y}}function rn(n){return e=>{const u=Wn(n),o=[];for(const c in u){const r=u[c];let s;typeof r=="function"?s=r(e):Array.isArray(r)?s=r:s=Array.from(new Set(e.map(a=>a[c]))),o.push(s.map(a=>({[c]:a})))}return Rn(o)}}function Rn(n){function t(u,o,c){if(!c.length&&o!=null){u.push(o);return}const r=c[0],s=c.slice(1);for(const a of r)t(u,{...o,...a},s)}const e=[];return t(e,null,n),e}function Wn(n){if(Array.isArray(n)){const t={};for(const e of n)t[e]=e;return t}else if(typeof n=="object")return n;return{[n]:n}}function un(n,t=1){let[e,u]=v.extent(n);const o=[];let c=e;for(;c<=u;)o.push(c),c+=t;return o}function V(n,t="day",e=1){let[u,o]=v.extent(n);const c=[];let r=new Date(u);for(;r<=o;)if(c.push(new Date(r)),t==="day"||t==="d"||t==="days")r.setUTCDate(r.getUTCDate()+1*e);else if(t==="week"||t==="w"||t==="weeks")r.setUTCDate(r.getUTCDate()+7*e);else if(t==="month"||t==="m"||t==="months")r.setUTCMonth(r.getUTCMonth()+1*e);else if(t==="year"||t==="y"||t==="years")r.setUTCFullYear(r.getUTCFullYear()+1*e);else throw new Error("Invalid granularity for date sequence: "+t);return c}function En(n,t){return function(u){t=t!=null?t:1;const o=typeof n=="function"?n:c=>c[n];return un(u.map(o),t)}}function Cn(n,t,e){return function(o){t=t!=null?t:"day",e=e!=null?e:1;const c=typeof n=="function"?n:r=>r[n];return V(o.map(c),t,e)}}function Vn(n,t,e){return function(o){t=t!=null?t:"day",e=e!=null?e:1;const c=typeof n=="function"?n:r=>r[n];return V(o.map(r=>new Date(c(r))),t,e).map(r=>r.toISOString())}}function on(n){return e=>{const u=[];for(const o of e){const c={...o};for(const r in n)c[r]==null&&(c[r]=n[r]);u.push(c)}return u}}function Un(n,t){return u=>{const o=rn(n)(u),c=x(u)(o);return t?on(t)(c):c}}function Bn(n){return e=>{const u=S(n),o={};return e.map(c=>{const r={...c};for(const s of u)r[s]!=null?o[s]=r[s]:o[s]!=null&&(r[s]=o[s]);return r})}}function Nn(n,t){return(u,o)=>{var c;let r="[tidy.debug";if((c=o==null?void 0:o.groupKeys)==null?void 0:c.length){const y=o.groupKeys.map(h=>h.join(": ")).join(", ");y.length&&(r+="|"+y)}t=t!=null?t:{};const{limit:s=10,output:a="table"}=t,f="--------------------------------------------------------------------------------";let d=f.length;const i=r+"]"+(n==null?"":" "+n);return d=Math.max(0,d-(i.length+2)),console.log(`${i} ${f.substring(0,d)}`),console[a](s==null||s>=u.length?u:u.slice(0,s)),u}}function T(n,t,e){return n==null||t==null?void 0:t===0&&n===0?0:!e&&t===0?void 0:n/t}var Jn=Object.freeze({__proto__:null,rate:T});function Hn(n,t,e){const u=typeof n=="function"?n:s=>s[n],o=typeof t=="function"?t:s=>s[t],{predicate:c,allowDivideByZero:r}=e!=null?e:{};return c==null?s=>{const a=o(s),f=u(s);return T(f,a,r)}:s=>{if(!c(s))return;const a=o(s),f=u(s);return T(f,a,r)}}function Pn(n){const t=typeof n=="function"?n:e=>e[n];return e=>Mn(e,t)}function Gn(n,t,e){const{partial:u=!1}=e!=null?e:{};return o=>o.map((c,r)=>{const s=r;if(!u&&s-n+1<0)return;const a=Math.max(0,s-n+1),f=o.slice(a,s+1);return t(f,s)})}function Yn(n){const t=typeof n=="function"?n:e=>e[n];return e=>v.min(e,t)}function Zn(n){const t=typeof n=="function"?n:e=>e[n];return e=>v.max(e,t)}function Qn(n){const t=typeof n=="function"?n:e=>e[n];return e=>jn(e,t)}function Xn(n,t){const e=typeof n=="function"?n:o=>o[n],u=typeof t=="function"?t:o=>o[t];return o=>{const c=W(o,e),r=W(o,u);return T(c,r)}}function xn(n){const t=typeof n=="function"?n:e=>e[n];return e=>v.median(e,t)}function ne(n){const t=typeof n=="function"?n:e=>e[n];return e=>v.deviation(e,t)}function ee(n){const t=typeof n=="function"?n:e=>e[n];return e=>v.variance(e,t)}function te(n){const t=typeof n=="function"?n:e=>e[n];return e=>t(e[0])}function re(n){const t=typeof n=="function"?n:e=>e[n];return e=>t(e[e.length-1])}function ue(n,t=!0){return e=>{const u=new RegExp(`^${n}`,t?"i":void 0);return w(e).filter(c=>u.test(c))}}function oe(n,t=!0){return e=>{const u=new RegExp(`${n}$`,t?"i":void 0);return w(e).filter(c=>u.test(c))}}function ce(n,t=!0){return e=>{const u=new RegExp(n,t?"i":void 0);return w(e).filter(c=>u.test(c))}}function se(n){return t=>w(t).filter(u=>n.test(u))}function le(n,t,e){return u=>{const o=w(u),c=[];for(let r=t[0];r<=t[1];++r){const s=e==null?r:new String("00000000"+r).slice(-e);c.push(`${n}${s}`)}return o.filter(r=>c.includes(r))}}function ae(n){return t=>{let e=new Set;for(const o of S(n))if(typeof o=="function"){const c=o(t);for(const r of c)e.add(r)}else e.add(o);return Array.from(e).map(o=>`-${o}`)}}l.TMath=Jn,l.addItems=tn,l.addRows=tn,l.arrange=I,l.asc=U,l.complete=Un,l.contains=ce,l.count=kn,l.cumsum=Pn,l.debug=Nn,l.desc=B,l.deviation=ne,l.distinct=an,l.endsWith=oe,l.everything=nn,l.expand=rn,l.fill=Bn,l.filter=cn,l.first=te,l.fixedOrder=fn,l.fullSeq=En,l.fullSeqDate=Cn,l.fullSeqDateISOString=Vn,l.groupBy=_,l.innerJoin=$n,l.last=re,l.leftJoin=x,l.map=ln,l.matches=se,l.max=Zn,l.mean=Qn,l.meanRate=Xn,l.median=xn,l.min=Yn,l.mutate=k,l.mutateWithSummary=zn,l.n=P,l.negate=ae,l.numRange=le,l.pick=C,l.pivotLonger=Dn,l.pivotWider=Tn,l.rate=Hn,l.rename=wn,l.replaceNully=on,l.roll=Gn,l.select=C,l.slice=E,l.sliceHead=Kn,l.sliceMax=On,l.sliceMin=In,l.sliceSample=An,l.sliceTail=Fn,l.sort=I,l.startsWith=ue,l.sum=G,l.summarize=D,l.summarizeAll=N,l.summarizeAt=H,l.summarizeIf=J,l.tally=Y,l.tidy=$,l.total=mn,l.totalAll=dn,l.totalAt=pn,l.totalIf=yn,l.transmute=Ln,l.variance=ee,l.vectorSeq=un,l.vectorSeqDate=V,l.when=sn,Object.defineProperty(l,"__esModule",{value:!0})});
(function(l,h){typeof exports=="object"&&typeof module!="undefined"?h(exports,require("d3-array")):typeof define=="function"&&define.amd?define(["exports","d3-array"],h):(l=typeof globalThis!="undefined"?globalThis:l||self,h(l.Tidy={},l.d3))})(this,function(l,h){"use strict";function z(n,...t){if(typeof n=="function")throw new Error("You must supply the data as the first argument to tidy()");let e=n;for(const r of t)e=r(e);return e}function on(n){return e=>e.filter(n)}function cn(n,t){return r=>{if(typeof n=="function"){if(!n(r))return r}else if(!n)return r;return z(r,...t)}}function sn(n){return e=>e.map(n)}function S(n){return n==null?[]:Array.isArray(n)?n:[n]}function ln(n){return e=>{if(n=S(n),!n.length){const u=new Set;for(const s of e)u.add(s);return Array.from(u)}const r=new Map,o=[],c=n[n.length-1];for(const u of e){let s=r,f=!1;for(const a of n){const d=typeof a=="function"?a(u):u[a];if(a===c){f=s.has(d),f||(o.push(u),s.set(d,!0));break}s.has(d)||s.set(d,new Map),s=s.get(d)}}return o}}function I(n){return e=>{const r=S(n).map(o=>typeof o=="function"?o:V(o));return e.slice().sort((o,c)=>{for(const u of r){const s=u(o,c);if(s!==0)return s}return 0})}}function V(n){return function(e,r){return h.ascending(e[n],r[n])}}function U(n){return function(e,r){return h.descending(e[n],r[n])}}function fn(n,t,e){let{position:r="start"}=e!=null?e:{};const o=r==="end"?-1:1,c=new Map;for(let s=0;s<t.length;++s)c.set(t[s],s);const u=typeof n=="function"?n:s=>s[n];return function(f,a){var d,i;const m=(d=c.get(u(f)))!=null?d:-1,y=(i=c.get(u(a)))!=null?i:-1;return m>=0&&y>=0?m-y:m>=0?o*-1:y>=0?o*1:0}}function D(n,t){return r=>{t=t!=null?t:{};const o={},c=Object.keys(n);for(const u of c)o[u]=n[u](r);if(t.rest&&r.length){const u=Object.keys(r[0]);for(const s of u)c.includes(s)||(o[s]=t.rest(s)(r))}return[o]}}function R(n,t,e,r){if(!n.length)return[];const o={};let c;if(r==null)c=Object.keys(n[0]);else{c=[];for(const u of S(r))typeof u=="function"?c.push(...u(n)):c.push(u)}for(const u of c){if(e){const s=n.map(f=>f[u]);if(!e(s))continue}o[u]=t(u)(n)}return[o]}function B(n){return e=>R(e,n)}function N(n,t){return r=>R(r,t,n)}function J(n,t){return r=>R(r,t,void 0,n)}function w(n){return e=>{const r=[];for(const o of e){const c={...o};for(const u in n){const s=n[u],f=typeof s=="function"?s(c):s;c[u]=f}r.push(c)}return r}}function an(n,t){return r=>{const o=D(n)(r),c=w(t)(o);return[...r,...c]}}function mn(n,t){return r=>{const o=B(n)(r),c=w(t)(o);return[...r,...c]}}function dn(n,t,e){return o=>{const c=N(n,t)(o),u=w(e)(c);return[...o,...u]}}function yn(n,t,e){return o=>{const c=J(n,t)(o),u=w(e)(c);return[...o,...u]}}function $(n,t){return{...n,...t.reduce((e,r)=>(e[r[0]]=r[1],e),{})}}function L(n,t,e,r,o,c=0){for(const[u,s]of n.entries()){const f=[...e,u];if(s instanceof Map){const a=r(t,f,c);L(s,a,f,r,o,c+1)}else o(t,f,s,c)}return t}function pn(n,t,e=r=>r[r.length-1]){function r(u,s){const f=new Map;return u.set(e(s),f),f}function o(u,s,f){u.set(e(s),t(f,s))}const c=new Map;return L(n,c,[],r,o),c}const O=n=>n;function _(n,t,e){return o=>{const c=gn(o,n),u=hn(c,t,e==null?void 0:e.addGroupKeys);if(e==null?void 0:e.export)switch(e.export){case"grouped":return u;case"entries":return k(u,{...e,export:"levels",levels:["entries"]});case"entries-object":case"entries-obj":case"entriesObject":return k(u,{...e,export:"levels",levels:["entries-object"]});case"object":return k(u,{...e,export:"levels",levels:["object"]});case"map":return k(u,{...e,export:"levels",levels:["map"]});case"keys":return k(u,{...e,export:"levels",levels:["keys"]});case"values":return k(u,{...e,export:"levels",levels:["values"]});case"levels":return k(u,e)}return vn(u,e==null?void 0:e.addGroupKeys)}}_.grouped=n=>({...n,export:"grouped"}),_.entries=n=>({...n,export:"entries"}),_.entriesObject=n=>({...n,export:"entries-object"}),_.object=n=>({...n,export:"object"}),_.map=n=>({...n,export:"map"}),_.keys=n=>({...n,export:"keys"}),_.values=n=>({...n,export:"values"}),_.levels=n=>({...n,export:"levels"});function hn(n,t,e){let r=n;if(!(t==null?void 0:t.length))return r;for(const o of t)r=pn(r,(c,u)=>{let f=o(c,{groupKeys:u});return e!==!1&&(f=f.map(a=>$(a,u))),f});return r}function gn(n,t){const e=S(t).map((o,c)=>{let u;typeof o=="function"?u=o.name?o.name:`group_${c}`:u=o.toString();const s=typeof o=="function"?o:a=>a[o],f=new Map;return a=>{const d=s(a);if(f.has(d))return f.get(d);const i=[u,d];return f.set(d,i),i}});return h.group(n,...e)}function vn(n,t){const e=[];return L(n,e,[],O,(r,o,c)=>{let u=c;t!==!1&&(u=c.map(s=>$(s,o))),r.push(...u)}),e}const _n=n=>n.join("/");function bn(n){var t;const{flat:e,single:r,mapLeaf:o=O,mapLeaves:c=O}=n;let u;return n.flat&&(u=(t=n.compositeKey)!=null?t:_n),{groupFn:(a,d)=>r?o($(a[0],d)):c(a.map(i=>o($(i,d)))),keyFn:e?a=>u(a.map(d=>d[1])):a=>a[a.length-1][1]}}function k(n,t){const{groupFn:e,keyFn:r}=bn(t);let{mapEntry:o=O}=t;const{levels:c=["entries"]}=t,u=[];for(const d of c)switch(d){case"entries":case"entries-object":case"entries-obj":case"entriesObject":{const i=d==="entries-object"||d==="entries-obj"||d==="entriesObject"?([m,y])=>({key:m,values:y}):o;u.push({id:"entries",createEmptySubgroup:()=>[],addSubgroup:(m,y,g,b)=>{m.push(i([g,y],b))},addLeaf:(m,y,g,b)=>{m.push(i([y,g],b))}});break}case"map":u.push({id:"map",createEmptySubgroup:()=>new Map,addSubgroup:(i,m,y)=>{i.set(y,m)},addLeaf:(i,m,y)=>{i.set(m,y)}});break;case"object":u.push({id:"object",createEmptySubgroup:()=>({}),addSubgroup:(i,m,y)=>{i[y]=m},addLeaf:(i,m,y)=>{i[m]=y}});break;case"keys":u.push({id:"keys",createEmptySubgroup:()=>[],addSubgroup:(i,m,y)=>{i.push([y,m])},addLeaf:(i,m)=>{i.push(m)}});break;case"values":u.push({id:"values",createEmptySubgroup:()=>[],addSubgroup:(i,m)=>{i.push(m)},addLeaf:(i,m,y)=>{i.push(y)}});break;default:typeof d=="object"&&u.push(d)}const s=(d,i,m)=>{var y,g;if(t.flat)return d;const b=(y=u[m])!=null?y:u[u.length-1],A=((g=u[m+1])!=null?g:b).createEmptySubgroup();return b.addSubgroup(d,A,r(i),m),A},f=(d,i,m,y)=>{var g;((g=u[y])!=null?g:u[u.length-1]).addLeaf(d,r(i),e(m,i),y)},a=u[0].createEmptySubgroup();return L(n,a,[],s,f)}function H(){return n=>n.length}function P(n){const t=typeof n=="function"?n:e=>e[n];return e=>h.fsum(e,t)}function G(n){return e=>{const{name:r="n",wt:o}=n!=null?n:{};return D({[r]:o==null?H():P(o)})(e)}}function Sn(n,t){return r=>{t=t!=null?t:{};const{name:o="n",sort:c}=t;return z(r,_(n,[G(t)]),c?I(U(o)):O)}}function jn(n){return e=>e.map(r=>{var o;const c={},u=Object.keys(r);for(const s of u){const f=(o=n[s])!=null?o:s;c[f]=r[s]}return c})}function W(n,t){return r=>r.slice(n,t)}const kn=n=>W(0,n),wn=n=>W(-n);function Mn(n,t){return r=>I(t)(r).slice(0,n)}function Kn(n,t){return r=>I(t)(r).slice(-n).reverse()}function Fn(n,t){t=t!=null?t:{};const{replace:e}=t;return o=>{if(!o.length)return o.slice();if(e){const c=[];for(let u=0;u<n;++u)c.push(o[Math.floor(Math.random()*o.length)]);return c}return h.shuffle(o.slice()).slice(0,n)}}function Y(n,t){if(n.length===0||t.length===0)return{};const e=Object.keys(n[0]),r=Object.keys(t[0]),o={};for(const c of e)r.includes(c)&&(o[c]=c);return o}function Z(n){if(Array.isArray(n)){const t={};for(const e of n)t[e]=e;return t}else if(typeof n=="object")return n;return{[n]:n}}function Q(n,t,e){for(const r in e){const o=e[r];if(n[o]!==t[r])return!1}return!0}function In(n,t){return r=>{const o=(t==null?void 0:t.by)==null?Y(r,n):Z(t.by);return r.flatMap(u=>n.filter(f=>Q(u,f,o)).map(f=>({...u,...f})))}}function X(n,t){return r=>{const o=(t==null?void 0:t.by)==null?Y(r,n):Z(t.by);return r.flatMap(u=>{const s=n.filter(f=>Q(u,f,o));return s.length?s.map(f=>({...u,...f})):u})}}function On(n){return e=>{const r=e.map(o=>({...o}));for(const o in n){const c=n[o],u=typeof c=="function"?c(r):c,s=(u==null?void 0:u[Symbol.iterator])&&typeof u!="string"?u:e.map(()=>u);let f=-1;for(const a of r)a[o]=s[++f]}return r}}function M(n){return n.length<1?[]:Object.keys(n[0])}function x(){return n=>M(n)}function nn(n,t){let e=[];for(const c of S(t))typeof c=="function"?e.push(...c(n)):e.push(c);e.length&&e[0][0]==="-"&&(e=[...x()(n),...e]);const r={},o=[];for(let c=e.length-1;c>=0;c--){const u=e[c];if(u[0]==="-"){r[u.substring(1)]=!0;continue}if(r[u]){r[u]=!1;continue}o.unshift(u)}return e=Array.from(new Set(o)),e}function E(n){return e=>{let r=nn(e,n);return r.length?e.map(o=>{const c={};for(const u of r)c[u]=o[u];return c}):e}}function An(n){return e=>{const r=w(n)(e);return E(Object.keys(n))(r)}}function en(n){return e=>typeof n=="function"?[...e,...S(n(e))]:[...e,...S(n)]}function zn(n){return e=>{const{namesFrom:r,valuesFrom:o,valuesFill:c,valuesFillMap:u,namesSep:s="_"}=n,f=Array.isArray(r)?r:[r],a=Array.isArray(o)?o:[o],d=[];if(!e.length)return d;const i=Object.keys(e[0]).filter(p=>!f.includes(p)&&!a.includes(p)),m={};for(const p of e)for(const v of f)m[v]==null&&(m[v]={}),m[v][p[v]]=!0;const y=[];for(const p in m)y.push(Object.keys(m[p]));const g={},b=$n(s,y);for(const p of b){if(a.length===1){g[p]=u!=null?u[a[0]]:c;continue}for(const v of a)g[`${v}${s}${p}`]=u!=null?u[v]:c}function K(p){if(!p.length)return[];const v={...g};for(const j of i)v[j]=p[0][j];for(const j of p){const q=f.map(F=>j[F]).join(s);if(a.length===1){v[q]=j[a[0]];continue}for(const F of a)v[`${F}${s}${q}`]=j[F]}return[v]}return i.length?z(e,_(i,[K])):K(e)}}function $n(n="_",t){function e(o,c,u){if(!u.length&&c!=null){o.push(c);return}const s=u[0],f=u.slice(1);for(const a of s)e(o,c==null?a:`${c}${n}${a}`,f)}const r=[];return e(r,null,t),r}function Ln(n){return e=>{var r;const{namesTo:o,valuesTo:c,namesSep:u="_"}=n,s=(r=n.cols)!=null?r:[],f=nn(e,s),a=Array.isArray(o)?o:[o],d=Array.isArray(c)?c:[c],i=a.length>1,m=d.length>1,y=[];for(const g of e){const b=Object.keys(g).filter(p=>!f.includes(p)),K={};for(const p of b)K[p]=g[p];const A=m?Array.from(new Set(f.map(p=>p.substring(p.indexOf(u)+1)))):f;for(const p of A){const v={...K};for(const j of d){const q=m?`${j}${u}${p}`:p,F=i?p.split(u):[p];let fe=0;for(const ae of a){const ie=F[fe++];v[ae]=ie,v[j]=g[q]}}y.push(v)}}return y}}function tn(n){return e=>{const r=qn(n),o=[];for(const c in r){const u=r[c];let s;typeof u=="function"?s=u(e):Array.isArray(u)?s=u:s=Array.from(new Set(e.map(f=>f[c]))),o.push(s.map(f=>({[c]:f})))}return Tn(o)}}function Tn(n){function t(r,o,c){if(!c.length&&o!=null){r.push(o);return}const u=c[0],s=c.slice(1);for(const f of u)t(r,{...o,...f},s)}const e=[];return t(e,null,n),e}function qn(n){if(Array.isArray(n)){const t={};for(const e of n)t[e]=e;return t}else if(typeof n=="object")return n;return{[n]:n}}function un(n,t=1){let[e,r]=h.extent(n);const o=[];let c=e;for(;c<=r;)o.push(c),c+=t;return o}function C(n,t="day",e=1){let[r,o]=h.extent(n);const c=[];let u=new Date(r);for(;u<=o;)if(c.push(new Date(u)),t==="day"||t==="d"||t==="days")u.setUTCDate(u.getUTCDate()+1*e);else if(t==="week"||t==="w"||t==="weeks")u.setUTCDate(u.getUTCDate()+7*e);else if(t==="month"||t==="m"||t==="months")u.setUTCMonth(u.getUTCMonth()+1*e);else if(t==="year"||t==="y"||t==="years")u.setUTCFullYear(u.getUTCFullYear()+1*e);else throw new Error("Invalid granularity for date sequence: "+t);return c}function Dn(n,t){return function(r){t=t!=null?t:1;const o=typeof n=="function"?n:c=>c[n];return un(r.map(o),t)}}function Rn(n,t,e){return function(o){t=t!=null?t:"day",e=e!=null?e:1;const c=typeof n=="function"?n:u=>u[n];return C(o.map(c),t,e)}}function Wn(n,t,e){return function(o){t=t!=null?t:"day",e=e!=null?e:1;const c=typeof n=="function"?n:u=>u[n];return C(o.map(u=>new Date(c(u))),t,e).map(u=>u.toISOString())}}function rn(n){return e=>{const r=[];for(const o of e){const c={...o};for(const u in n)c[u]==null&&(c[u]=n[u]);r.push(c)}return r}}function En(n,t){return r=>{const o=tn(n)(r),c=X(r)(o);return t?rn(t)(c):c}}function Cn(n){return e=>{const r=S(n),o={};return e.map(c=>{const u={...c};for(const s of r)u[s]!=null?o[s]=u[s]:o[s]!=null&&(u[s]=o[s]);return u})}}function Vn(n,t){return(r,o)=>{var c;let u="[tidy.debug";if((c=o==null?void 0:o.groupKeys)==null?void 0:c.length){const y=o.groupKeys.map(g=>g.join(": ")).join(", ");y.length&&(u+="|"+y)}t=t!=null?t:{};const{limit:s=10,output:f="table"}=t,a="--------------------------------------------------------------------------------";let d=a.length;const i=u+"]"+(n==null?"":" "+n);return d=Math.max(0,d-(i.length+2)),console.log(`${i} ${a.substring(0,d)}`),console[f](s==null||s>=r.length?r:r.slice(0,s)),r}}function T(n,t,e){return n==null||t==null?void 0:t===0&&n===0?0:!e&&t===0?void 0:n/t}var Un=Object.freeze({__proto__:null,rate:T});function Bn(n,t,e){const r=typeof n=="function"?n:s=>s[n],o=typeof t=="function"?t:s=>s[t],{predicate:c,allowDivideByZero:u}=e!=null?e:{};return c==null?s=>{const f=o(s),a=r(s);return T(a,f,u)}:s=>{if(!c(s))return;const f=o(s),a=r(s);return T(a,f,u)}}function Nn(n,t){let e=new h.Adder,r=0;return Float64Array.from(n,o=>e.add(+(t(o,r++,n)||0)))}function Jn(n,t){let e=0;for(let r=0;r<n.length;++r){const o=t(n[r],r,n);+o===o&&(e+=1)}return e?h.fsum(n,t)/e:void 0}function Hn(n){const t=typeof n=="function"?n:e=>e[n];return e=>Nn(e,t)}function Pn(n,t,e){const{partial:r=!1}=e!=null?e:{};return o=>o.map((c,u)=>{const s=u;if(!r&&s-n+1<0)return;const f=Math.max(0,s-n+1),a=o.slice(f,s+1);return t(a,s)})}function Gn(n){const t=typeof n=="function"?n:e=>e[n];return e=>h.min(e,t)}function Yn(n){const t=typeof n=="function"?n:e=>e[n];return e=>h.max(e,t)}function Zn(n){const t=typeof n=="function"?n:e=>e[n];return e=>Jn(e,t)}function Qn(n,t){const e=typeof n=="function"?n:o=>o[n],r=typeof t=="function"?t:o=>o[t];return o=>{const c=h.fsum(o,e),u=h.fsum(o,r);return T(c,u)}}function Xn(n){const t=typeof n=="function"?n:e=>e[n];return e=>h.median(e,t)}function xn(n){const t=typeof n=="function"?n:e=>e[n];return e=>h.deviation(e,t)}function ne(n){const t=typeof n=="function"?n:e=>e[n];return e=>h.variance(e,t)}function ee(n){const t=typeof n=="function"?n:e=>e[n];return e=>t(e[0])}function te(n){const t=typeof n=="function"?n:e=>e[n];return e=>t(e[e.length-1])}function ue(n,t=!0){return e=>{const r=new RegExp(`^${n}`,t?"i":void 0);return M(e).filter(c=>r.test(c))}}function re(n,t=!0){return e=>{const r=new RegExp(`${n}$`,t?"i":void 0);return M(e).filter(c=>r.test(c))}}function oe(n,t=!0){return e=>{const r=new RegExp(n,t?"i":void 0);return M(e).filter(c=>r.test(c))}}function ce(n){return t=>M(t).filter(r=>n.test(r))}function se(n,t,e){return r=>{const o=M(r),c=[];for(let u=t[0];u<=t[1];++u){const s=e==null?u:new String("00000000"+u).slice(-e);c.push(`${n}${s}`)}return o.filter(u=>c.includes(u))}}function le(n){return t=>{let e=new Set;for(const o of S(n))if(typeof o=="function"){const c=o(t);for(const u of c)e.add(u)}else e.add(o);return Array.from(e).map(o=>`-${o}`)}}l.TMath=Un,l.addItems=en,l.addRows=en,l.arrange=I,l.asc=V,l.complete=En,l.contains=oe,l.count=Sn,l.cumsum=Hn,l.debug=Vn,l.desc=U,l.deviation=xn,l.distinct=ln,l.endsWith=re,l.everything=x,l.expand=tn,l.fill=Cn,l.filter=on,l.first=ee,l.fixedOrder=fn,l.fullSeq=Dn,l.fullSeqDate=Rn,l.fullSeqDateISOString=Wn,l.groupBy=_,l.innerJoin=In,l.last=te,l.leftJoin=X,l.map=sn,l.matches=ce,l.max=Yn,l.mean=Zn,l.meanRate=Qn,l.median=Xn,l.min=Gn,l.mutate=w,l.mutateWithSummary=On,l.n=H,l.negate=le,l.numRange=se,l.pick=E,l.pivotLonger=Ln,l.pivotWider=zn,l.rate=Bn,l.rename=jn,l.replaceNully=rn,l.roll=Pn,l.select=E,l.slice=W,l.sliceHead=kn,l.sliceMax=Kn,l.sliceMin=Mn,l.sliceSample=Fn,l.sliceTail=wn,l.sort=I,l.startsWith=ue,l.sum=P,l.summarize=D,l.summarizeAll=B,l.summarizeAt=J,l.summarizeIf=N,l.tally=G,l.tidy=z,l.total=an,l.totalAll=mn,l.totalAt=yn,l.totalIf=dn,l.transmute=An,l.variance=ne,l.vectorSeq=un,l.vectorSeqDate=C,l.when=cn,Object.defineProperty(l,"__esModule",{value:!0})});
//# sourceMappingURL=tidy.min.js.map
{
"name": "@tidyjs/tidy",
"version": "2.0.3",
"version": "2.0.4",
"description": "Tidy up your data with JavaScript, inspired by dplyr and the tidyverse",

@@ -47,3 +47,3 @@ "main": "dist/lib/index.js",

},
"gitHead": "ede1e053b62e4ee9af50d857ee59cbb6dbce344e"
"gitHead": "c67eb2b718760f57554686c350c150d42dd1191a"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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