@flourish/interpreter
Advanced tools
Comparing version 6.0.2 to 6.0.3
@@ -937,5 +937,8 @@ (function (global, factory) { | ||
} | ||
return Object.freeze({ | ||
test: test, | ||
parse: shield(function(str) { return parser(str) || customDatetimeParser(CUSTOM_FORMAT_REGEXES[format_string])(str); }), | ||
parse: shield(function(str) { | ||
return parser(str) || (CUSTOM_FORMAT_REGEXES[format_string] ? customDatetimeParser(CUSTOM_FORMAT_REGEXES[format_string])(str) : null); | ||
}), | ||
format: function(dt) { return formatter(dt); }, | ||
@@ -942,0 +945,0 @@ type: "datetime", |
{ | ||
"name": "@flourish/interpreter", | ||
"version": "6.0.2", | ||
"version": "6.0.3", | ||
"description": "Does a best guess at the type of data supplied", | ||
@@ -5,0 +5,0 @@ "main": "interpreter.js", |
@@ -0,1 +1,4 @@ | ||
# 6.0.3 | ||
* Interpret non-parseable datetime strings as strings | ||
# 6.0.2 | ||
@@ -2,0 +5,0 @@ * Add datetime interpretations for strings containing 4-letter month abbreviations |
@@ -67,5 +67,8 @@ import { timeFormat, timeParse } from "d3-time-format"; | ||
} | ||
return Object.freeze({ | ||
test: test, | ||
parse: shield(function(str) { return parser(str) || customDatetimeParser(CUSTOM_FORMAT_REGEXES[format_string])(str); }), | ||
parse: shield(function(str) { | ||
return parser(str) || (CUSTOM_FORMAT_REGEXES[format_string] ? customDatetimeParser(CUSTOM_FORMAT_REGEXES[format_string])(str) : null); | ||
}), | ||
format: function(dt) { return formatter(dt); }, | ||
@@ -72,0 +75,0 @@ type: "datetime", |
@@ -205,2 +205,19 @@ const { expect } = require("chai"); | ||
}); | ||
it("should parse empty strings as null", () => { | ||
var datetime_ids = createInterpreter.DATETIME_IDS; | ||
datetime_ids.forEach(id => { | ||
const interpretation = createInterpreter.getInterpretation(id); | ||
expect(interpretation.parse("") === null).to.equal(true); | ||
}); | ||
}); | ||
it("should parse non-empty strings that do not represent validly formatted dates as null", () => { | ||
const values = ["doremifasola", "!-+%$^", "111222333"]; // strings that definitely do not represent validly formatted datetimes | ||
var datetime_ids = createInterpreter.DATETIME_IDS; | ||
datetime_ids.forEach(id => { | ||
const interpretation = createInterpreter.getInterpretation(id); | ||
expect(values.every(d => interpretation.parse(d) === null)).to.equal(true); | ||
}); | ||
}); | ||
}); | ||
@@ -207,0 +224,0 @@ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
95847
2091
0