Skip to content

Commit

Permalink
bump deps
Browse files Browse the repository at this point in the history
- upgrade eslint
- use npm-run-all
  • Loading branch information
commenthol committed Nov 17, 2018
1 parent 0dcc4bb commit 7bf4506
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 127 deletions.
38 changes: 20 additions & 18 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "date-chinese",
"version": "1.0.5",
"version": "1.0.6-0",
"description": "Chinese Calendar",
"keywords": [
"calendar",
Expand All @@ -20,22 +20,23 @@
"bugs": {
"url": "https://github.com/commenthol/date-chinese/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/commenthol/date-chinese.git"
},
"license": "MIT",
"author": "commenthol <commenthol@gmail.com>",
"main": "lib",
"directories": {
"test": "test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/commenthol/date-chinese.git"
},
"scripts": {
"all": "npm run clean && npm run lint && npm run build && npm test",
"all": "npm-run-all clean lint build test",
"build": "babel -d lib src",
"build:es5": "BABEL_ENV=es5 babel -d es src",
"clean": "rimraf lib es coverage .nyc_output",
"clean:all": "rimraf node_modules && npm run clean",
"clean:all": "npm-run-all clean clean:node_modules",
"clean:node_modules": "rimraf node_modules",
"coverage": "nyc -r text -r html npm test",
"lint": "eslint '**/*.js'",
"prepublishOnly": "npm run all",
Expand Down Expand Up @@ -77,22 +78,23 @@
]
},
"dependencies": {
"astronomia": "^2.0.0"
"astronomia": "^2.0.1"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-core": "^6.26.3",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-2": "^6.24.1",
"babel-register": "^6.26.0",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.7.0",
"eslint-plugin-standard": "^3.0.1",
"mocha": "^5.0.5",
"nyc": "^11.6.0",
"eslint": "^5.9.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"mocha": "^5.2.0",
"npm-run-all": "^4.1.3",
"nyc": "^13.1.0",
"rimraf": "^2.6.2"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src/Chinese.js
Expand Up @@ -277,7 +277,7 @@ export default class CalendarChinese {
this._cache.lon[jde] = lon
let lonDeg = lon * p - 1e-13
let term = (2 + Math.floor(lonDeg / 30)) % 12 + 1
return {term: term, lon: lonDeg}
return { term: term, lon: lonDeg }
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Expand Up @@ -3,7 +3,7 @@
* @license MIT
*/

export {default as CalendarChinese} from './Chinese'
export {default as CalendarKorean} from './Korean'
export {default as CalendarVietnamese} from './Vietnamese'
export {default as CalendarJapanese} from './Japanese'
export { default as CalendarChinese } from './Chinese'
export { default as CalendarKorean } from './Korean'
export { default as CalendarVietnamese } from './Vietnamese'
export { default as CalendarJapanese } from './Japanese'
110 changes: 55 additions & 55 deletions test/chinese.test.js
Expand Up @@ -6,9 +6,9 @@
process.env.TZ = 'Asia/Shanghai'

const assert = require('assert')
const {julian} = require('astronomia')
const { julian } = require('astronomia')

const {CalendarChinese} = require('../src')
const { CalendarChinese } = require('../src')

function toDate (jde) {
return new julian.Calendar().fromJDE(jde).toDate()
Expand All @@ -21,35 +21,35 @@ describe('#CalendarChinese', function () {
it('can construct via new', function () {
cal = new CalendarChinese(78, 1, 10, true, 9)
assert.ok(cal instanceof CalendarChinese)
assert.deepEqual(cal.get(), exp)
assert.deepStrictEqual(cal.get(), exp)
})

it('can construct with class instance', function () {
let cal1 = new CalendarChinese(cal)
assert.ok(cal1 instanceof CalendarChinese)
assert.ok(cal1 !== cal)
assert.deepEqual(cal.get(), exp)
assert.deepStrictEqual(cal.get(), exp)
})

it('can construct with array', function () {
let cal1 = new CalendarChinese(exp)
assert.ok(cal1 !== cal)
assert.deepEqual(cal.get(), exp)
assert.deepStrictEqual(cal.get(), exp)
})
})

describe('conversions', function () {
var tests = [
{date: new Date('1980-12-03T00:00:00+0800'), chinese: [77, 57, 10, false, 26]},
{date: new Date('2017-01-28T00:00:00+0800'), chinese: [78, 34, 1, false, 1]},
{date: new Date('1988-02-21T15:59:59.255Z'), chinese: [78, 5, 1, false, 6]} // special condition for `midnight` where jde === mn
{ date: new Date('1980-12-03T00:00:00+0800'), chinese: [77, 57, 10, false, 26] },
{ date: new Date('2017-01-28T00:00:00+0800'), chinese: [78, 34, 1, false, 1] },
{ date: new Date('1988-02-21T15:59:59.255Z'), chinese: [78, 5, 1, false, 6] } // special condition for `midnight` where jde === mn
]

describe('from Date to chinese', function () {
tests.forEach((test) => {
it(test.date.toISOString(), function () {
var cal = new CalendarChinese().fromDate(test.date)
assert.deepEqual(cal.get(), test.chinese)
assert.deepStrictEqual(cal.get(), test.chinese)
})
})
})
Expand All @@ -64,7 +64,7 @@ describe('#CalendarChinese', function () {
var cal = new CalendarChinese()
cal.set.apply(cal, test.chinese)
// console.log(cal.toDate().toISOString()) // gap is ~ 3seconds
assert.equal(stripIsoSeconds(cal.toDate()), stripIsoSeconds(test.date))
assert.strictEqual(stripIsoSeconds(cal.toDate()), stripIsoSeconds(test.date))
})
})

Expand All @@ -73,33 +73,33 @@ describe('#CalendarChinese', function () {
it('special case at 1935-04-01', function () {
var cal = new CalendarChinese(77, 12, 2, false, 29)
// console.log(cal.toDate().toISOString())
assert.equal(stripIsoSeconds(cal.toDate()), '1935-04-01T15:59:00Z')
assert.strictEqual(stripIsoSeconds(cal.toDate()), '1935-04-01T15:59:00Z')
})
})
})

describe('midnight', function () {
const tests = [
{d: '1984-12-19T23:59:00+0800', exp: '1984-12-19T00:00:00+0800'},
{d: '1984-12-20T00:00:00+0800', exp: '1984-12-20T00:00:00+0800'},
{d: '1984-12-20T00:01:00+0800', exp: '1984-12-20T00:00:00+0800'},
{d: '1928-01-01T00:14:20+0800', exp: '1928-01-01T00:14:20+0800'},
{d: '1928-01-01T00:00:00+0800', exp: '1927-12-31T00:14:20+0800'}
{ d: '1984-12-19T23:59:00+0800', exp: '1984-12-19T00:00:00+0800' },
{ d: '1984-12-20T00:00:00+0800', exp: '1984-12-20T00:00:00+0800' },
{ d: '1984-12-20T00:01:00+0800', exp: '1984-12-20T00:00:00+0800' },
{ d: '1928-01-01T00:14:20+0800', exp: '1928-01-01T00:14:20+0800' },
{ d: '1928-01-01T00:00:00+0800', exp: '1927-12-31T00:14:20+0800' }
]
const cal = new CalendarChinese()
tests.forEach(function (t) {
it(t.d, function () {
let c = new julian.Calendar().fromDate(new Date(t.d))
let mn = cal.midnight(c.toJDE())
assert.equal(toDate(mn).toISOString(), new Date(t.exp).toISOString())
assert.strictEqual(toDate(mn).toISOString(), new Date(t.exp).toISOString())
})
})

it('can call midnight twice', function () {
let c = new julian.Calendar().fromDate(new Date(tests[1].d))
let mn = cal.midnight(c.toJDE())
mn = cal.midnight(mn)
assert.equal(toDate(mn).toISOString(), new Date(tests[1].exp).toISOString())
assert.strictEqual(toDate(mn).toISOString(), new Date(tests[1].exp).toISOString())
})
})

Expand All @@ -123,12 +123,12 @@ describe('#CalendarChinese', function () {

describe('qingming', function () {
var tests = [
['1740', {year: 1740, month: 4, day: 4}, '1740-04-04T00:00:00.000Z'],
['1900', {year: 1900, month: 4, day: 5}, '1900-04-05T00:00:00.000Z'],
['1981', {year: 1981, month: 4, day: 5}, '1981-04-05T00:00:00.000Z'],
['2001', {year: 2001, month: 4, day: 5}, '2001-04-05T00:00:00.000Z'],
['2010', {year: 2010, month: 4, day: 5}, '2010-04-05T00:00:00.000Z'],
['2016', {year: 2016, month: 4, day: 4}, '2016-04-04T00:00:00.000Z']
['1740', { year: 1740, month: 4, day: 4 }, '1740-04-04T00:00:00.000Z'],
['1900', { year: 1900, month: 4, day: 5 }, '1900-04-05T00:00:00.000Z'],
['1981', { year: 1981, month: 4, day: 5 }, '1981-04-05T00:00:00.000Z'],
['2001', { year: 2001, month: 4, day: 5 }, '2001-04-05T00:00:00.000Z'],
['2010', { year: 2010, month: 4, day: 5 }, '2010-04-05T00:00:00.000Z'],
['2016', { year: 2016, month: 4, day: 4 }, '2016-04-04T00:00:00.000Z']
]

tests.forEach(function (test) {
Expand All @@ -138,12 +138,12 @@ describe('#CalendarChinese', function () {
let qm = cal.qingming(y)
cal.fromJDE(qm)
let gre = cal.toGregorian()
assert.deepEqual(gre, test[1])
assert.deepStrictEqual(gre, test[1])
// converting to Gregorian using jde
let gcal = new julian.CalendarGregorian().fromJDE(qm)
let ts = cal.timeshiftUTC(gcal)
let date = new Date(+(gcal.toDate()) + ts * 86400000)
assert.equal(date.toISOString(), test[2])
assert.strictEqual(date.toISOString(), test[2])
})
})
})
Expand Down Expand Up @@ -184,8 +184,8 @@ describe('#CalendarChinese', function () {
let st = cal.solarTerm(t, y)
// converting to Gregorian
let gre = cal.fromJDE(st).toGregorian()
assert.deepEqual(cal.get(), test[2])
assert.deepEqual([gre.year, gre.month, gre.day], test[1])
assert.deepStrictEqual(cal.get(), test[2])
assert.deepStrictEqual([gre.year, gre.month, gre.day], test[1])
})
})
})
Expand All @@ -202,7 +202,7 @@ describe('#CalendarChinese', function () {
let st = cal.majorSolarTerm(t, y)
// converting to Gregorian
let gre = cal.fromJDE(st).toGregorian()
assert.deepEqual([gre.year, gre.month, gre.day], test[1])
assert.deepStrictEqual([gre.year, gre.month, gre.day], test[1])
})
})
})
Expand All @@ -219,36 +219,36 @@ describe('#CalendarChinese', function () {
let st = cal.minorSolarTerm(t, y)
// converting to Gregorian
let gre = cal.fromJDE(st).toGregorian()
assert.deepEqual([gre.year, gre.month, gre.day], test[1])
assert.deepStrictEqual([gre.year, gre.month, gre.day], test[1])
})
})
})

describe('Gregorian', function () {
var tests = [
{d: [-2636, 2, 15], ch: [1, 1, 1, false, 1]},
{d: [-2635, 2, 15], ch: [1, 2, 1, false, 13]},
{d: [0, 1, 1], ch: [44, 56, 12, false, 9]},
{d: [1, 1, 1], ch: [44, 57, 11, false, 21]},
{d: [2, 1, 1], ch: [44, 58, 12, false, 2]},
{d: [1582, 10, 15], ch: [71, 19, 9, false, 19]},
{d: [1582, 10, 16], ch: [71, 19, 9, false, 20]},
{d: [1582, 10, 17], ch: [71, 19, 9, false, 21]},
{d: [1600, 1, 1], ch: [71, 36, 11, false, 16]},
{d: [1980, 10, 28], ch: [77, 57, 9, false, 20]},
{d: [1984, 11, 20], ch: [78, 1, 10, false, 28]},
{d: [1984, 12, 1], ch: [78, 1, 10, true, 9]},
{d: [1985, 1, 28], ch: [78, 1, 12, false, 8]},
{d: [1985, 2, 28], ch: [78, 2, 1, false, 9]},
{d: [1985, 7, 19], ch: [78, 2, 6, false, 2]},
{d: [1986, 12, 28], ch: [78, 3, 11, false, 27]},
{d: [2000, 1, 1], ch: [78, 16, 11, false, 25]},
{d: [2015, 7, 15], ch: [78, 32, 5, false, 30]},
{d: [2015, 12, 31], ch: [78, 32, 11, false, 21]},
{d: [2016, 2, 6], ch: [78, 32, 12, false, 28]},
{d: [2016, 2, 7], ch: [78, 32, 12, false, 29]},
{d: [2016, 2, 8], ch: [78, 33, 1, false, 1]},
{d: [2017, 9, 18], ch: [78, 34, 7, false, 28]}
{ d: [-2636, 2, 15], ch: [1, 1, 1, false, 1] },
{ d: [-2635, 2, 15], ch: [1, 2, 1, false, 13] },
{ d: [0, 1, 1], ch: [44, 56, 12, false, 9] },
{ d: [1, 1, 1], ch: [44, 57, 11, false, 21] },
{ d: [2, 1, 1], ch: [44, 58, 12, false, 2] },
{ d: [1582, 10, 15], ch: [71, 19, 9, false, 19] },
{ d: [1582, 10, 16], ch: [71, 19, 9, false, 20] },
{ d: [1582, 10, 17], ch: [71, 19, 9, false, 21] },
{ d: [1600, 1, 1], ch: [71, 36, 11, false, 16] },
{ d: [1980, 10, 28], ch: [77, 57, 9, false, 20] },
{ d: [1984, 11, 20], ch: [78, 1, 10, false, 28] },
{ d: [1984, 12, 1], ch: [78, 1, 10, true, 9] },
{ d: [1985, 1, 28], ch: [78, 1, 12, false, 8] },
{ d: [1985, 2, 28], ch: [78, 2, 1, false, 9] },
{ d: [1985, 7, 19], ch: [78, 2, 6, false, 2] },
{ d: [1986, 12, 28], ch: [78, 3, 11, false, 27] },
{ d: [2000, 1, 1], ch: [78, 16, 11, false, 25] },
{ d: [2015, 7, 15], ch: [78, 32, 5, false, 30] },
{ d: [2015, 12, 31], ch: [78, 32, 11, false, 21] },
{ d: [2016, 2, 6], ch: [78, 32, 12, false, 28] },
{ d: [2016, 2, 7], ch: [78, 32, 12, false, 29] },
{ d: [2016, 2, 8], ch: [78, 33, 1, false, 1] },
{ d: [2017, 9, 18], ch: [78, 34, 7, false, 28] }
]

describe('fromGregorian', function () {
Expand All @@ -257,7 +257,7 @@ describe('#CalendarChinese', function () {
let [y, m, d] = t.d
it(t.d.join('-'), function () {
cal.fromGregorian(y, m, d)
assert.deepEqual([cal.cycle, cal.year, cal.month, cal.leap, cal.day], t.ch)
assert.deepStrictEqual([cal.cycle, cal.year, cal.month, cal.leap, cal.day], t.ch)
})
})
})
Expand All @@ -268,7 +268,7 @@ describe('#CalendarChinese', function () {
it(t.d.join('-') + ' ' + [cycle, year, month, leap, day].join('-'), function () {
let cal = new CalendarChinese(cycle, year, month, leap, day)
let res = cal.toGregorian()
assert.deepEqual([res.year, res.month, res.day], t.d)
assert.deepStrictEqual([res.year, res.month, res.day], t.d)
})
})
})
Expand Down
10 changes: 5 additions & 5 deletions test/japanese.test.js
Expand Up @@ -4,9 +4,9 @@
'use strict'

const assert = require('assert')
const {julian} = require('astronomia')
const { julian } = require('astronomia')

const {CalendarJapanese} = require('../src')
const { CalendarJapanese } = require('../src')

process.env.TZ = 'Asia/Tokyo'

Expand Down Expand Up @@ -64,7 +64,7 @@ describe('#CalendarJapanese', function () {
let [y, m, d] = t.d
it(t.d.join('-'), function () {
cal.fromGregorian(y, m, d)
assert.deepEqual([cal.cycle, cal.year, cal.month, cal.leap, cal.day], t.ch)
assert.deepStrictEqual([cal.cycle, cal.year, cal.month, cal.leap, cal.day], t.ch)
})
})
})
Expand All @@ -75,7 +75,7 @@ describe('#CalendarJapanese', function () {
it(t.d.join('-') + ' ' + [cycle, year, month, leap, day].join('-'), function () {
let cal = new CalendarJapanese(cycle, year, month, leap, day)
let res = cal.toGregorian()
assert.deepEqual([res.year, res.month, res.day], t.d)
assert.deepStrictEqual([res.year, res.month, res.day], t.d)
})
})
})
Expand Down Expand Up @@ -126,7 +126,7 @@ describe('#CalendarJapanese', function () {
it([year, test.sekki].join(' '), function () {
let jde = cal.solarTerm(test.sekki, year)
let res = new julian.CalendarGregorian().fromJDE(jde).toDate().toISOString()
assert.equal(res, new Date(test.exp).toISOString())
assert.strictEqual(res, new Date(test.exp).toISOString())
})
})
})
Expand Down

0 comments on commit 7bf4506

Please sign in to comment.