New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@datasketch/taco

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datasketch/taco - npm Package Compare versions

Comparing version
0.2.0
to
0.2.1
+8
ava.config.js
export default {
extensions: {
ts: 'module'
},
nodeArguments: [
'--loader=ts-node/esm'
]
}
type FactoryObject = {
editorName: string;
formatterName: string;
config: (format: Record<string, any>) => {
editorParams: Record<string, any>;
formatterParams: Record<string, any>;
};
};
type Factory = {
[x: string]: FactoryObject;
};
type FactoryResult = {
editor: string;
formatter: string;
editorParams: Record<string, any>;
formatterParams: Record<string, any>;
};
export declare const factory: Factory;
export declare const getFactory: (hdType: string, format?: Record<string, any>) => FactoryResult;
export {};
export declare const factories: Record<string, {
name: string;
config: (format: Record<string, any>) => Record<string, any>;
}>;
declare function getFormatter(hdType: string, format?: Record<string, any>): {
formatter: string | Function;
formatterParams: Record<string, any>;
};
export { getFormatter };
import test from 'ava'
import { getColumnDefinitions } from '../src/columns.js'
import iris from './fixtures/iris.json' assert { type: 'json' }
import books from './fixtures/books.json' assert { type: 'json' }
test('it outputs column definition for iris dict', t => {
const expected = [
{
field: 'sepal_length',
title: 'Sepal.Length',
editor: 'number'
},
{
field: 'sepal_width',
title: 'Sepal.Width',
editor: 'number'
},
{
field: 'petal_length',
title: 'Petal.Length',
editor: 'number'
},
{
field: 'petal_width',
title: 'Petal.Width',
editor: 'number'
},
{
field: 'species',
title: 'Species',
editor: 'list',
editorParams: {
autocomplete: true,
multiselect: false,
values: ['setosa', 'versicolor', 'virginica']
}
}
]
const columnDefinitions = getColumnDefinitions(iris)
t.deepEqual(columnDefinitions.length, expected.length)
t.deepEqual(columnDefinitions, expected)
})
test('it outputs column definition for books dict', t => {
const expected = [
{
field: 'title',
title: 'Title'
},
{
field: 'author',
title: 'Author'
},
{
field: 'cover',
title: 'Cover',
formatter: 'image',
formatterParams: {
height: '150px'
}
}
]
const columnDefinitions = getColumnDefinitions(books)
t.deepEqual(columnDefinitions.length, expected.length)
t.deepEqual(columnDefinitions, expected)
})
[
{
"id": "title",
"label": "Title",
"hdType": "Txt"
},
{
"id": "author",
"label": "Author",
"hdType": "Txt"
},
{
"id": "cover",
"label": "Cover",
"hdType": "Img"
}
]
[
{
"id": "sepal_length",
"label": "Sepal.Length",
"hdType": "Num"
},
{
"id": "sepal_width",
"label": "Sepal.Width",
"hdType": "Num"
},
{
"id": "petal_length",
"label": "Petal.Length",
"hdType": "Num"
},
{
"id": "petal_width",
"label": "Petal.Width",
"hdType": "Num"
},
{
"id": "species",
"label": "Species",
"hdType": "Cat",
"format": {
"categories": [
"setosa",
"versicolor",
"virginica"
]
}
}
]
+1
-1

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

const r={Cat:{name:"list",config:r=>({values:r.categories,autocomplete:!0,multiselect:!1})}};function t(t){if(!Array.isArray(t))throw new Error("Dictionary must be an array");return t.map((t=>{const{editor:e,editorParams:a}=function(t,e={}){const a=r[t];return a?{editor:a.name,editorParams:a.config(e)}:{editor:"input",editorParams:{}}}(t.hdType,t.format);return{title:t.label,field:t.id,editor:e,editorParams:a}}))}export{t as getColumnDefinitions};
const r={editorName:"input",formatterName:"plaintext"},t={Cat:Object.assign(Object.assign({},r),{editorName:"list",config:r=>({editorParams:{values:r.categories,autocomplete:!0,multiselect:!1},formatterParams:{}})}),Num:Object.assign(Object.assign({},r),{editorName:"number",config:r=>({editorParams:{},formatterParams:{}})}),Bin:{editorName:"tickCross",formatterName:"tickCross",config:r=>({editorParams:{},formatterParams:{}})}};function a(a){if(!Array.isArray(a))throw new Error("Dictionary must be an array");return a.map((a=>Object.assign({title:a.label,field:a.id},((a,e={})=>{const o=t[a];if(!o){const{editorName:t,formatterName:a}=r;return{editor:t,formatter:a,editorParams:{},formatterParams:{}}}const{editorName:m,formatterName:i}=o,{editorParams:s,formatterParams:n}=o.config(e);return{editor:m,formatter:i,editorParams:s,formatterParams:n}})(a.hdType,a.format))))}export{a as getColumnDefinitions};

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

var Taco=function(t){"use strict";const r={Cat:{name:"list",config:t=>({values:t.categories,autocomplete:!0,multiselect:!1})}};return t.getColumnDefinitions=function(t){if(!Array.isArray(t))throw new Error("Dictionary must be an array");return t.map((t=>{const{editor:e,editorParams:i}=function(t,e={}){const i=r[t];return i?{editor:i.name,editorParams:i.config(e)}:{editor:"input",editorParams:{}}}(t.hdType,t.format);return{title:t.label,field:t.id,editor:e,editorParams:i}}))},t}({});
var Taco=function(r){"use strict";const t={editorName:"input",formatterName:"plaintext"},a={Cat:Object.assign(Object.assign({},t),{editorName:"list",config:r=>({editorParams:{values:r.categories,autocomplete:!0,multiselect:!1},formatterParams:{}})}),Num:Object.assign(Object.assign({},t),{editorName:"number",config:r=>({editorParams:{},formatterParams:{}})}),Bin:{editorName:"tickCross",formatterName:"tickCross",config:r=>({editorParams:{},formatterParams:{}})}};return r.getColumnDefinitions=function(r){if(!Array.isArray(r))throw new Error("Dictionary must be an array");return r.map((r=>Object.assign({title:r.label,field:r.id},((r,e={})=>{const o=a[r];if(!o){const{editorName:r,formatterName:a}=t;return{editor:r,formatter:a,editorParams:{},formatterParams:{}}}const{editorName:i,formatterName:m}=o,{editorParams:s,formatterParams:n}=o.config(e);return{editor:i,formatter:m,editorParams:s,formatterParams:n}})(r.hdType,r.format))))},r}({});

@@ -5,10 +5,12 @@ type Field = {

hdType: string;
format: Record<string, any>;
format?: Record<string, any>;
};
declare function getColumnDefinitions(dictionary: Field[]): {
editor: string;
formatter: string;
editorParams: Record<string, any>;
formatterParams: Record<string, any>;
title: string;
field: string;
editor: string | Function;
editorParams: Record<string, any>;
}[];
export { getColumnDefinitions };

@@ -1,4 +0,8 @@

export declare const factories: Record<string, {
name: string;
config: (format: Record<string, any>) => Record<string, any>;
}>;
type FactoryObject = {
[x: string]: {
name: string;
config: (format: Record<string, any>) => Record<string, any>;
};
};
export declare const factories: FactoryObject;
export {};
{
"name": "@datasketch/taco",
"version": "0.2.0",
"version": "0.2.1",
"description": "",

@@ -9,7 +9,9 @@ "main": "dist/taco.es.js",

"scripts": {
"build": "del-cli dist && rollup -c"
"build": "del-cli dist && rollup -c",
"test": "ava tests/*",
"start": "ava --watch"
},
"keywords": [],
"author": "",
"license": "ISC",
"author": "David Daza <david@datasketch.co>",
"license": "MIT",
"devDependencies": {

@@ -29,5 +31,10 @@ "@rollup/plugin-terser": "^0.4.1",

},
"engines": {
"node": "18"
}
"repository": {
"type": "git",
"url": "git+https://github.com/datasketch/taco.git"
},
"bugs": {
"url": "https://github.com/datasketch/taco/issues"
},
"homepage": "https://github.com/datasketch/taco#readme"
}

@@ -5,3 +5,4 @@ {

"lib": ["es6"],
"module": "ES2020",
"module": "ESNext",
"moduleResolution": "nodenext",
"rootDir": "src",

@@ -17,4 +18,6 @@ "declaration": true,

"noImplicitAny": true,
"skipLibCheck": true
}
"skipLibCheck": true,
"resolveJsonModule": true
},
"exclude": ["tests"]
}
import { getEditor } from './editor/index.js'
type Field = {
id: string
label: string
hdType: string
format: Record<string, any>
}
function getColumnDefinitions (dictionary: Field[]) {
if (!Array.isArray(dictionary)) {
throw new Error('Dictionary must be an array')
}
return dictionary.map(field => {
const { editor, editorParams } = getEditor(field.hdType, field.format)
return {
title: field.label,
field: field.id,
editor,
editorParams
}
})
}
export { getColumnDefinitions }
export const factories: Record<string, { name: string, config: (format: Record<string, any>) => Record<string, any>}> = {
Cat: {
name: 'list',
config: (format: Record<string, any>) => ({
values: format.categories,
autocomplete: true,
multiselect: false
})
}
}
import { factories } from './factories.js'
function getEditor (hdType: string, format: Record<string, any> = {}): { editor: string | Function; editorParams: Record<string, any> } {
const factory = factories[hdType]
if (!factory) {
return {
editor: 'input',
editorParams: {}
}
}
return { editor: factory.name, editorParams: factory.config(format) }
}
export { getEditor }
export * from './columns.js'