Skip to content

Commit

Permalink
Pretified and fixed datetime miliseconds issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ppaska committed Apr 5, 2022
1 parent 098c0f7 commit edec931
Show file tree
Hide file tree
Showing 23 changed files with 1,192 additions and 856 deletions.
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"printWidth": 100,
"trailingComma": "none",
"arrowParens": "avoid",
"parser": "typescript",
"singleQuote": true,
"tabWidth": 2
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "datapipe-js",
"version": "0.3.21",
"version": "0.3.22",
"description": "dataPipe is a data processing and data analytics library for JavaScript. Inspired by LINQ (C#) and Pandas (Python)",
"main": "dist/cjs/data-pipe.js",
"module": "dist/esm/data-pipe.mjs",
Expand Down
28 changes: 15 additions & 13 deletions src/_internals.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { Selector } from "./types";
import { dateToString } from "./utils";
import { Selector } from './types';
import { dateToString } from './utils';

export function fieldSelector(input: string | string[] | Selector<any, string>): Selector<any, string> {
if (typeof input === "function") {
return input;
} else if (typeof input === "string") {
return (item): any => item[input] instanceof Date ? dateToString(item[input]) : item[input];
} else if (Array.isArray(input)) {
return (item): any => input.map(r => item[r]).join('|');
} else {
throw Error(`Unknown input. Can't create a fieldSelector`)
}
}
export function fieldSelector(
input: string | string[] | Selector<any, string>
): Selector<any, string> {
if (typeof input === 'function') {
return input;
} else if (typeof input === 'string') {
return (item): any => (item[input] instanceof Date ? dateToString(item[input]) : item[input]);
} else if (Array.isArray(input)) {
return (item): any => input.map(r => item[r]).join('|');
} else {
throw Error(`Unknown input. Can't create a fieldSelector`);
}
}
8 changes: 4 additions & 4 deletions src/array/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './joins'
export * from './stats'
export * from './transform'
export * from './utils'
export * from './joins';
export * from './stats';
export * from './transform';
export * from './utils';
Loading

0 comments on commit edec931

Please sign in to comment.