ddf-time-utils
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,6 +0,6 @@ | ||
export declare const YEAR_TYPE: symbol; | ||
export declare const QUARTER_TYPE: symbol; | ||
export declare const MONTH_TYPE: symbol; | ||
export declare const WEEK_TYPE: symbol; | ||
export declare const DATE_TYPE: symbol; | ||
export declare const YEAR_TYPE: unique symbol; | ||
export declare const QUARTER_TYPE: unique symbol; | ||
export declare const MONTH_TYPE: unique symbol; | ||
export declare const WEEK_TYPE: unique symbol; | ||
export declare const DATE_TYPE: unique symbol; | ||
export declare const TIME_TYPES: symbol[]; | ||
@@ -7,0 +7,0 @@ export declare const TIME_TYPES_AS_STRINGS: string[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const lodash_1 = require("lodash"); | ||
const uniq = require("lodash/uniq"); | ||
const head = require("lodash/head"); | ||
const isString = require("lodash/isString"); | ||
const isArray = require("lodash/isArray"); | ||
const compact = require("lodash/compact"); | ||
const flatten = require("lodash/flatten"); | ||
const concat = require("lodash/concat"); | ||
const range = require("lodash/range"); | ||
const moment_1 = require("moment"); | ||
@@ -51,3 +58,3 @@ const TWO_DIGITS_MIN_NUMBER = 10; | ||
exports.TIME_TYPES_AS_STRINGS = exports.TIME_TYPES.map(Symbol.keyFor); | ||
exports.TIME_TYPES_DDF_COMPATIBLE = lodash_1.concat('time', exports.TIME_TYPES_AS_STRINGS.map(key => key.replace(/_TYPE/, '').toLowerCase())); | ||
exports.TIME_TYPES_DDF_COMPATIBLE = concat('time', exports.TIME_TYPES_AS_STRINGS.map(key => key.replace(/_TYPE/, '').toLowerCase())); | ||
function extractLocalTimeRange(type) { | ||
@@ -72,6 +79,6 @@ function parse(option) { | ||
} | ||
lodash_1.range(startYear, endYear + 1).forEach(year => { | ||
range(startYear, endYear + 1).forEach(year => { | ||
const startValue = year === startYear ? startSecondMatch : settings.minLimit; | ||
const endValue = year === endYear ? endSecondMatch : settings.maxLimit; | ||
lodash_1.range(startValue, endValue + 1).forEach(valueParam => { | ||
range(startValue, endValue + 1).forEach(valueParam => { | ||
const value = isZeroAppendNeeded(valueParam) ? `0${valueParam}` : valueParam; | ||
@@ -88,3 +95,3 @@ result.push(year + settings.divider + value); | ||
const fYear = Number(parsed.end[0]); | ||
return lodash_1.range(sYear, fYear + 1) | ||
return range(sYear, fYear + 1) | ||
.map(year => `${year}`); | ||
@@ -104,10 +111,10 @@ }, | ||
const endDay = Number(parsed.end[THIRD_ELEMENT]); | ||
lodash_1.range(startYear, endYear + 1).forEach(year => { | ||
range(startYear, endYear + 1).forEach(year => { | ||
const currentStartMonth = year === startYear ? startMonth : 1; | ||
const currentEndMonth = year === endYear ? endMonth : MAX_MONTH; | ||
lodash_1.range(currentStartMonth, currentEndMonth + 1).forEach(month => { | ||
range(currentStartMonth, currentEndMonth + 1).forEach(month => { | ||
const monthStr = month < TWO_DIGITS_MIN_NUMBER ? `0${month}` : month; | ||
const currentStartDay = year === startYear && month === currentStartMonth ? startDay : 1; | ||
const currentEndDay = year === endYear && month === currentEndMonth ? endDay : MAX_DAY; | ||
lodash_1.range(currentStartDay, currentEndDay + 1).forEach(day => { | ||
range(currentStartDay, currentEndDay + 1).forEach(day => { | ||
const dayStr = day < TWO_DIGITS_MIN_NUMBER ? `0${day}` : day; | ||
@@ -124,7 +131,7 @@ result.push(`${year}${monthStr}${dayStr}`); | ||
function detectTimeType(timeQuery) { | ||
const plainTimeQuery = lodash_1.isArray(timeQuery) ? lodash_1.flatten(timeQuery) : [timeQuery]; | ||
const timeTypes = lodash_1.uniq(lodash_1.flatten(plainTimeQuery | ||
const plainTimeQuery = isArray(timeQuery) ? flatten(timeQuery) : [timeQuery]; | ||
const timeTypes = uniq(flatten(plainTimeQuery | ||
.map(queryDetail => Object.getOwnPropertySymbols(TIME_TYPE_PATTERNS) | ||
.filter(type => TIME_TYPE_PATTERNS[type].regularExp.test(queryDetail))))); | ||
return timeTypes.length === 1 ? lodash_1.head(timeTypes) : null; | ||
return timeTypes.length === 1 ? head(timeTypes) : null; | ||
} | ||
@@ -140,6 +147,6 @@ exports.detectTimeType = detectTimeType; | ||
let result = null; | ||
if (lodash_1.isString(option)) { | ||
if (isString(option)) { | ||
result = option; | ||
} | ||
if (lodash_1.isArray(option)) { | ||
if (isArray(option)) { | ||
result = extractor(option); | ||
@@ -149,3 +156,3 @@ } | ||
} | ||
return lodash_1.compact(lodash_1.flatten(query.map(option => getTimeByQueryType(option)))); | ||
return compact(flatten(query.map(option => getTimeByQueryType(option)))); | ||
} | ||
@@ -152,0 +159,0 @@ exports.getTimeRange = getTimeRange; |
{ | ||
"name": "ddf-time-utils", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Gapminder DDF time utils", | ||
@@ -33,26 +33,26 @@ "main": "./lib/index.js", | ||
"dependencies": { | ||
"@types/lodash": "4.14.85", | ||
"@types/moment": "2.13.0", | ||
"@types/node": "8.0.53", | ||
"lodash": "4.17.4", | ||
"moment": "2.19.2" | ||
"lodash": "4.17.10", | ||
"moment": "2.22.2" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "4.0.5", | ||
"@types/lodash": "4.14.109", | ||
"@types/moment": "2.13.0", | ||
"@types/node": "10.3.1", | ||
"@types/chai": "4.1.3", | ||
"@types/deep-diff": "0.0.31", | ||
"@types/es6-shim": "0.31.35", | ||
"@types/mocha": "2.2.44", | ||
"@types/es6-shim": "0.31.37", | ||
"@types/mocha": "5.2.1", | ||
"chai": "4.1.2", | ||
"codecov": "3.0.0", | ||
"codecov": "3.0.2", | ||
"compare-version": "0.1.2", | ||
"conventional-changelog": "1.1.7", | ||
"conventional-changelog-cli": "1.3.5", | ||
"conventional-github-releaser": "2.0.0", | ||
"conventional-changelog": "2.0.0", | ||
"conventional-changelog-cli": "2.0.0", | ||
"conventional-github-releaser": "3.1.0", | ||
"istanbul": "0.4.5", | ||
"mocha": "4.0.1", | ||
"sinon": "4.1.2", | ||
"sinon-chai": "2.14.0", | ||
"ts-node": "^3.3.0", | ||
"typescript": "2.6.1" | ||
"mocha": "5.2.0", | ||
"sinon": "5.0.10", | ||
"sinon-chai": "3.1.0", | ||
"ts-node": "6.1.0", | ||
"typescript": "2.9.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
2
215
0
60784
19
+ Addedlodash@4.17.10(transitive)
+ Addedmoment@2.22.2(transitive)
- Removed@types/lodash@4.14.85
- Removed@types/moment@2.13.0
- Removed@types/node@8.0.53
- Removed@types/lodash@4.14.85(transitive)
- Removed@types/moment@2.13.0(transitive)
- Removed@types/node@8.0.53(transitive)
- Removedlodash@4.17.4(transitive)
- Removedmoment@2.19.2(transitive)
Updatedlodash@4.17.10
Updatedmoment@2.22.2