json-e
Advanced tools
Comparing version 4.5.3 to 4.6.0
@@ -812,9 +812,9 @@ (function (global, factory) { | ||
'^(\\s*(-|\\+))?', | ||
'(\\s*(\\d+)\\s*y((ears?)|r)?)?', | ||
'(\\s*(\\d+)\\s*mo(nths?)?)?', | ||
'(\\s*(\\d+)\\s*w((eeks?)|k)?)?', | ||
'(\\s*(\\d+)\\s*d(ays?)?)?', | ||
'(\\s*(\\d+)\\s*h((ours?)|r)?)?', | ||
'(\\s*(\\d+)\\s*m(in(utes?)?)?)?', | ||
'(\\s*(\\d+)\\s*s(ec(onds?)?)?)?', | ||
'(\\s*(?<years>\\d+)\\s*(y|year|years|yr))?', | ||
'(\\s*(?<months>\\d+)\\s*(months|month|mo))?', | ||
'(\\s*(?<weeks>\\d+)\\s*(weeks|week|wk|w))?', | ||
'(\\s*(?<days>\\d+)\\s*(days|day|d))?', | ||
'(\\s*(?<hours>\\d+)\\s*(hours|hour|hr|h))?', | ||
'(\\s*(?<minutes>\\d+)\\s*(minutes|minute|min|m))?', | ||
'(\\s*(?<seconds>\\d+)\\s*(seconds|second|sec|s))?', | ||
'\\s*$', | ||
@@ -833,10 +833,11 @@ ].join(''), 'i'); | ||
// Return parsed values | ||
let groups = match.groups; | ||
return { | ||
years: parseInt(match[4] || 0, 10) * neg, | ||
months: parseInt(match[8] || 0, 10) * neg, | ||
weeks: parseInt(match[11] || 0, 10) * neg, | ||
days: parseInt(match[15] || 0, 10) * neg, | ||
hours: parseInt(match[18] || 0, 10) * neg, | ||
minutes: parseInt(match[22] || 0, 10) * neg, | ||
seconds: parseInt(match[25] || 0, 10) * neg, | ||
years: parseInt(groups['years'] || 0, 10) * neg, | ||
months: parseInt(groups['months'] || 0, 10) * neg, | ||
weeks: parseInt(groups['weeks'] || 0, 10) * neg, | ||
days: parseInt(groups['days'] || 0, 10) * neg, | ||
hours: parseInt(groups['hours'] || 0, 10) * neg, | ||
minutes: parseInt(groups['minutes'] || 0, 10) * neg, | ||
seconds: parseInt(groups['seconds'] || 0, 10) * neg, | ||
}; | ||
@@ -1288,3 +1289,3 @@ }; | ||
var child_context = Object.assign(context, variables); | ||
var child_context = Object.assign({}, context, variables); | ||
@@ -1624,3 +1625,3 @@ if (template.in == undefined) { | ||
var src = (template, context = {}) => { | ||
if (typeof context !== 'object') { | ||
if (!isObject(context)) { | ||
throw new TemplateError('context must be an object'); | ||
@@ -1627,0 +1628,0 @@ } |
{ | ||
"name": "json-e", | ||
"version": "4.5.3", | ||
"version": "4.6.0", | ||
"description": "json parameterization module inspired from json-parameterization", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -5,9 +5,9 @@ // Regular expression matching: | ||
'^(\\s*(-|\\+))?', | ||
'(\\s*(\\d+)\\s*y((ears?)|r)?)?', | ||
'(\\s*(\\d+)\\s*mo(nths?)?)?', | ||
'(\\s*(\\d+)\\s*w((eeks?)|k)?)?', | ||
'(\\s*(\\d+)\\s*d(ays?)?)?', | ||
'(\\s*(\\d+)\\s*h((ours?)|r)?)?', | ||
'(\\s*(\\d+)\\s*m(in(utes?)?)?)?', | ||
'(\\s*(\\d+)\\s*s(ec(onds?)?)?)?', | ||
'(\\s*(?<years>\\d+)\\s*(y|year|years|yr))?', | ||
'(\\s*(?<months>\\d+)\\s*(months|month|mo))?', | ||
'(\\s*(?<weeks>\\d+)\\s*(weeks|week|wk|w))?', | ||
'(\\s*(?<days>\\d+)\\s*(days|day|d))?', | ||
'(\\s*(?<hours>\\d+)\\s*(hours|hour|hr|h))?', | ||
'(\\s*(?<minutes>\\d+)\\s*(minutes|minute|min|m))?', | ||
'(\\s*(?<seconds>\\d+)\\s*(seconds|second|sec|s))?', | ||
'\\s*$', | ||
@@ -26,10 +26,11 @@ ].join(''), 'i'); | ||
// Return parsed values | ||
let groups = match.groups; | ||
return { | ||
years: parseInt(match[4] || 0, 10) * neg, | ||
months: parseInt(match[8] || 0, 10) * neg, | ||
weeks: parseInt(match[11] || 0, 10) * neg, | ||
days: parseInt(match[15] || 0, 10) * neg, | ||
hours: parseInt(match[18] || 0, 10) * neg, | ||
minutes: parseInt(match[22] || 0, 10) * neg, | ||
seconds: parseInt(match[25] || 0, 10) * neg, | ||
years: parseInt(groups['years'] || 0, 10) * neg, | ||
months: parseInt(groups['months'] || 0, 10) * neg, | ||
weeks: parseInt(groups['weeks'] || 0, 10) * neg, | ||
days: parseInt(groups['days'] || 0, 10) * neg, | ||
hours: parseInt(groups['hours'] || 0, 10) * neg, | ||
minutes: parseInt(groups['minutes'] || 0, 10) * neg, | ||
seconds: parseInt(groups['seconds'] || 0, 10) * neg, | ||
}; | ||
@@ -36,0 +37,0 @@ }; |
@@ -168,3 +168,3 @@ /* eslint-disable */ | ||
var child_context = Object.assign(context, variables); | ||
var child_context = Object.assign({}, context, variables); | ||
@@ -504,3 +504,3 @@ if (template.in == undefined) { | ||
module.exports = (template, context = {}) => { | ||
if (typeof context !== 'object') { | ||
if (!isObject(context)) { | ||
throw new TemplateError('context must be an object'); | ||
@@ -507,0 +507,0 @@ } |
101121
2765