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

@flourish/interpreter

Package Overview
Dependencies
Maintainers
10
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@flourish/interpreter - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

test/.eslintrc.json

3

.eslintrc.json

@@ -6,6 +6,3 @@ {

"extends": "plugin:@flourish/flourish/flourish",
"rules": {
"space-before-blocks": ["error", "always"]
},
"env": { "browser": true }
}
{
"name": "@flourish/interpreter",
"version": "0.1.0",
"version": "0.2.0",
"description": "Does a best guess at the type of data supplied",
"main": "interpreter.js",
"module": "src/index.js",
"directories": {
"test": "test"
},
"main": "src/index.js",
"scripts": {
"build": "rollup -c",
"lint": "eslint src",
"minify": "uglifyjs -m -o interpreter.min.js interpreter.js",
"prepare": "npm run build && npm run minify",
"minify": "uglifyjs -m -o interpreter.min.js interpreter.js",
"lint": "eslint src"
"pretest": "npm run build",
"test": "mocha"
},

@@ -23,11 +21,13 @@ "author": "Kiln Enterprises Ltd",

"dependencies": {
"d3-time-format": "^2.0.5",
"rollup": "^0.41.1",
"rollup-plugin-node-resolve": "^3.0.0",
"uglify-js": "^2.7.5"
"d3-time-format": "^2.0.5"
},
"devDependencies": {
"chai": "^4.2.0",
"@flourish/eslint-plugin-flourish": "^0.7.2",
"eslint": "git://github.com/robinhouston/eslint.git#bug-ignoredNodes",
"pre-commit": "^1.2.2"
"eslint": "^6.4.0",
"mocha": "^6.2.0",
"rollup": "^1.21.4",
"rollup-plugin-node-resolve": "^5.2.0",
"pre-commit": "^1.2.2",
"uglify-js": "^2.7.5"
},

@@ -34,0 +34,0 @@ "precommit": [

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

# 0.2.0
* Add 1pm and 01/86 formats
* Drop Tue and Tuesday formats
* Allow usage of accessor function for second argument of intepreter
* Convert second arguments that aren't undefined, functions or strings to strings (allows for array indexing with numbers)
* Add a few basic tests
# 0.1.0
* Improve date handling
* Add longitude and latitude types
import nodeResolve from "rollup-plugin-node-resolve";
export default {
entry: "src/index.js",
format: "umd",
moduleName: "interpreter",
dest: "interpreter.js",
plugins: [
nodeResolve()
]
input: "src/index.js",
output: {
file: "interpreter.js",
format: "umd",
name: "interpreter"
},
plugins: [
nodeResolve()
],
onwarn: function (warning, warn) {
if (warning.code === "CIRCULAR_DEPENDENCY") return;
if (warning.code === "UNRESOLVED_IMPORT") {
throw new Error(
"Couldn't resolve the dependency " + warning.source +
" (from " + warning.importer + "): sometimes you can" +
" fix this with 'npm install', or add '" + warning.source +
" to 'external'. See: " + warning.url
);
}
warn(warning);
}
};

@@ -6,9 +6,15 @@ import { datetime_interpreters } from "./types/datetime";

function createParserTest(val) { return function(func) { return func.test(val); }; }
function createParserTest(val) { return function(interpreter) { return interpreter.test(val); }; }
function _createAccessorFunction(arr, accessor) {
if (accessor === undefined) return function(index) { return arr[index]; };
if (typeof accessor === "function") return function(index) { return accessor(arr[index], index); };
return function(index) { return arr[index]["" + accessor]; };
}
function createInterpreter(n_max) {
n_max = n_max > 0 ? n_max : 1000;
return function(arr, prop) {
return function(arr, accessor) {
if (!Array.isArray(arr)) return undefined;

@@ -18,11 +24,6 @@ if (!arr.length) return string_interpreters.slice();

var n = Math.min(n_max, arr.length);
var getVal = (function() {
if (typeof prop !== "string") return function(index) { return arr[index]; };
return function(index) { return arr[index] ? arr[index][prop] : undefined; };
})();
var getVal = _createAccessorFunction(arr, accessor);
var interpreters = datetime_interpreters.concat(number_interpreters, coordinate_interpreters);
for (var i = 0; i<n && interpreters.length; i++) {
for (var i = 0; i < n && interpreters.length; i++) {
var val = getVal(i);

@@ -37,2 +38,2 @@ if (val) interpreters = interpreters.filter(createParserTest(val));

export { createInterpreter };
export { createInterpreter, _createAccessorFunction };

@@ -35,2 +35,3 @@ import { timeFormat, timeParse } from "d3-time-format";

createDatetimeInterpreter("%d-%b-%y"),
createDatetimeInterpreter("%m/%y"),
createDatetimeInterpreter("%m/%Y"),

@@ -46,6 +47,5 @@ createDatetimeInterpreter("%b %Y"),

createDatetimeInterpreter("%b"),
createDatetimeInterpreter("%A"),
createDatetimeInterpreter("%a"),
createDatetimeInterpreter("%X"),
createDatetimeInterpreter("%I:%M %p"),
createDatetimeInterpreter("%I%p"),
createDatetimeInterpreter("%H:%M")

@@ -52,0 +52,0 @@ ]);

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