Skip to content

Commit 3d1198f

Browse files
committed
Target ES5 builds
1 parent cbbaac2 commit 3d1198f

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"prepare": "npm run build",
1717
"prepublishOnly": "npm test && npm run lint",
1818
"preversion": "npm run lint",
19-
"test": "rm -rf dist/ && npm run build && TZ='UTC' npx mocha test",
19+
"test": "rm -rf lib/ && npm run build && TZ='UTC' npx mocha test",
2020
"version": "npm run format && git add -A src"
2121
},
2222
"repository": {

src/models/operations.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import * as dateFn from 'date-fns';
2-
import { Snap } from '../constants';
2+
import { Sign, Snap } from '../constants';
33

44
export const operations: any = {
5-
'+': {
5+
[Sign.plus]: {
66
s: dateFn.addSeconds,
77
m: dateFn.addMinutes,
88
h: dateFn.addHours,
99
d: dateFn.addDays,
1010
w: dateFn.addWeeks,
1111
M: dateFn.addMonths,
1212
},
13-
'-': {
13+
[Sign.minus]: {
1414
s: dateFn.subSeconds,
1515
m: dateFn.subMinutes,
1616
h: dateFn.subHours,

src/parser/parsetoken.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { Sign, Snap, NOW } from '../constants';
22
import { Token } from '../models/Token';
33
import { TokenModifier } from '../models/TokenModifier';
44

5+
export const includes = (target: string, searchString: string) => target.indexOf(searchString) > -1;
6+
57
export function parseToken(token: string = NOW): Token {
68
const regex = /^(?:now)?(?:([+\-])(?:(\d+)?([smhdwM])))*(?:[@\/]([smhdwM]|(?:bw)))?$/g;
79
const matches = regex.exec(token);
@@ -12,7 +14,7 @@ export function parseToken(token: string = NOW): Token {
1214
throw error;
1315
}
1416

15-
if (token.includes('-') || token.includes('+')) {
17+
if (includes(token, Sign.minus) || includes(token, Sign.plus)) {
1618
const modifierRegex = /([+\-])(\d+)?([smhdwM])?/g;
1719
let modifierMatches = modifierRegex.exec(token);
1820

@@ -35,8 +37,8 @@ export function parseToken(token: string = NOW): Token {
3537
}
3638
}
3739

38-
const snapFrom = token.includes(Snap.beginning);
39-
const snapTo = token.includes(Snap.end);
40+
const snapFrom = includes(token, Snap.beginning);
41+
const snapTo = includes(token, Snap.end);
4042

4143
if (snapFrom || snapTo) {
4244
const snapRegex = /[\/@]([smhdwM]|(?:bw))/;

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"target": "es6",
3+
"target": "es5",
44
"module": "commonjs",
55
"declaration": true,
66
"outDir": "./lib",

0 commit comments

Comments
 (0)