Skip to content

Commit

Permalink
Add lightFormat function and optimize toDate
Browse files Browse the repository at this point in the history
  • Loading branch information
kossnocorp committed Dec 13, 2018
1 parent ea59e6c commit 9b0d043
Show file tree
Hide file tree
Showing 12 changed files with 1,506 additions and 720 deletions.
49 changes: 25 additions & 24 deletions config/karma.js
@@ -1,11 +1,11 @@
process.env.PHANTOMJS_BIN = 'node_modules/.bin/phantomjs'
process.env.NODE_ENV = 'test'

var webpackConfig = require('./webpack')
var countReporter = require('./_lib/countReporter')
var benchmarkJSONReporter = require('./_lib/benchmarkJSONReporter')
const webpackConfig = require('./webpack')
const countReporter = require('./_lib/countReporter')
const benchmarkJSONReporter = require('./_lib/benchmarkJSONReporter')

var sauceLabsLaunchers = {
const sauceLabsLaunchers = {
// TODO: See if Safari became more reliable
safari: {
base: 'SauceLabs',
Expand Down Expand Up @@ -83,13 +83,13 @@ var sauceLabsLaunchers = {
}
}

var localLaunchers = {
const localLaunchers = {
LocalChrome: {
base: 'Chrome'
}
}

var travisLaunchers = {
const travisLaunchers = {
ChromeTravis: {
base: 'ChromeHeadless',
// NOTE: We need to launch Chrome with --no-sandbox.
Expand All @@ -98,7 +98,7 @@ var travisLaunchers = {
}
}

function config (config) {
function config(config) {
config.set({
frameworks: getFrameworksConfig(),
files: getFilesConfig(),
Expand All @@ -119,10 +119,10 @@ function config (config) {
// so waiting time must be insanely high.
browserNoActivityTimeout: process.env.TEST_CROSS_BROWSER
? 60 * 60 * 1000 /* 1 hour */
: 10 * 1000, /* 10 sec */
: 10 * 1000 /* 10 sec */,
captureTimeout: process.env.TEST_CROSS_BROWSER
? 120 * 1000 /* 2 min */
: 60 * 1000, /* 1 min */
: 60 * 1000 /* 1 min */,

sauceLabs: {
startConnect: false,
Expand All @@ -146,48 +146,49 @@ function config (config) {
'karma-webpack',
'karma-benchmark',
'karma-benchmark-reporter',
{'reporter:count': ['type', countReporter]},
{'reporter:benchmark-json': ['type', benchmarkJSONReporter]}
{ 'reporter:count': ['type', countReporter] },
{ 'reporter:benchmark-json': ['type', benchmarkJSONReporter] }
],

customLaunchers: process.env.TEST_CROSS_BROWSER ? sauceLabsLaunchers : process.env.TRAVIS ? travisLaunchers : localLaunchers,
customLaunchers: process.env.TEST_CROSS_BROWSER
? sauceLabsLaunchers
: process.env.TRAVIS
? travisLaunchers
: localLaunchers,
browsers: getBrowsersConfig(),
reporters: getReportersConfig()
})
}

function getFrameworksConfig () {
function getFrameworksConfig() {
if (process.env.TEST_BENCHMARK) {
return ['benchmark']
} else {
return ['mocha', 'sinon']
}
}

function getFilesConfig () {
function getFilesConfig() {
if (process.env.USE_STATIC_TESTS) {
return ['../tmp/tests.js']
} else if (process.env.TEST_BENCHMARK) {
return [
'../node_modules/moment/moment.js',
'../benchmark.js'
]
return ['../node_modules/moment/moment.js', '../benchmark.js']
} else {
return ['../test.js']
}
}

function getPreprocessorsConfig () {
function getPreprocessorsConfig() {
if (process.env.USE_STATIC_TESTS) {
return {'../tmp/tests.js': ['sourcemap']}
return { '../tmp/tests.js': ['sourcemap'] }
} else if (process.env.TEST_BENCHMARK) {
return {'../benchmark.js': ['webpack', 'sourcemap']}
return { '../benchmark.js': ['webpack', 'sourcemap'] }
} else {
return {'../test.js': ['webpack', 'sourcemap']}
return { '../test.js': ['webpack', 'sourcemap'] }
}
}

function getBrowsersConfig () {
function getBrowsersConfig() {
if (process.env.TEST_CROSS_BROWSER) {
return Object.keys(sauceLabsLaunchers)
} else if (process.env.TEST_BENCHMARK) {
Expand All @@ -199,7 +200,7 @@ function getBrowsersConfig () {
}
}

function getReportersConfig () {
function getReportersConfig() {
if (process.env.TEST_CROSS_BROWSER) {
return ['dots', 'saucelabs', 'count']
} else if (process.env.TEST_BENCHMARK) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -77,6 +77,7 @@
"power-assert": "^1.3.1",
"prettier": "^1.14.3",
"sinon": "^1.17.3",
"size-limit": "^0.21.0",
"snazzy": "^7.0.0",
"systemjs": "^0.19.39",
"systemjs-plugin-babel": "0.0.17",
Expand Down
8 changes: 8 additions & 0 deletions src/_lib/addLeadingZeros/index.js
@@ -0,0 +1,8 @@
export default function addLeadingZeros(number, targetLength) {
var sign = number < 0 ? '-' : ''
var output = Math.abs(number).toString()
while (output.length < targetLength) {
output = '0' + output
}
return sign + output
}

0 comments on commit 9b0d043

Please sign in to comment.