date-holidays 3.40.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/data/countries/AF.todo +78 -0
- package/data/countries/AQ.todo +18 -0
- package/data/countries/BT.todo +50 -0
- package/data/countries/BV.todo +11 -0
- package/data/countries/CP.todo +11 -0
- package/data/countries/DG.todo +10 -0
- package/data/countries/FK.todo +9 -0
- package/data/countries/FM.todo +20 -0
- package/data/countries/GS.todo +9 -0
- package/data/countries/HM.todo +10 -0
- package/data/countries/IO.todo +9 -0
- package/data/countries/IQ.todo +46 -0
- package/data/countries/JO.todo +34 -0
- package/data/countries/KG.todo +28 -0
- package/data/countries/KH.todo +60 -0
- package/data/countries/KI.todo +18 -0
- package/data/countries/KP.todo +32 -0
- package/data/countries/KW.todo +22 -0
- package/data/countries/LA.todo +46 -0
- package/data/countries/LB.todo +26 -0
- package/data/countries/MH.todo +65 -0
- package/data/countries/MM.todo +40 -0
- package/data/countries/MN.todo +56 -0
- package/data/countries/MO.todo +9 -0
- package/data/countries/MP.todo +9 -0
- package/data/countries/MV.todo +73 -0
- package/data/countries/NP.todo +53 -0
- package/data/countries/NR.todo +38 -0
- package/data/countries/NU.todo +9 -0
- package/data/countries/OM.todo +32 -0
- package/data/countries/PG.todo +55 -0
- package/data/countries/PN.todo +9 -0
- package/data/countries/PS.todo +43 -0
- package/data/countries/PW.todo +42 -0
- package/data/countries/QA.todo +24 -0
- package/data/countries/SB.todo +30 -0
- package/data/countries/SY.todo +38 -0
- package/data/countries/TF.todo +11 -0
- package/data/countries/TJ.todo +18 -0
- package/data/countries/TK.todo +9 -0
- package/data/countries/TL.todo +36 -0
- package/data/countries/TM.todo +22 -0
- package/data/countries/TV.todo +26 -0
- package/data/countries/UM.todo +30 -0
- package/data/countries/WS.todo +32 -0
- package/data/countries/YE.todo +54 -0
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.LICENSE.txt +0 -18
- package/dist/index.min.js.map +1 -1
- package/dist/umd.min.js +1 -1
- package/dist/umd.min.js.LICENSE.txt +0 -18
- package/dist/umd.min.js.map +1 -1
- package/lib/Holidays.cjs +40 -7
- package/lib/index.cjs +15 -2
- package/package.json +39 -21
- package/scripts/holidays2json.js +238 -0
- package/src/Holidays.js +39 -6
- package/src/browser.js +9 -0
- package/src/index.js +9 -1
- package/src/plugins.js +1 -0
- package/types/index.d.ts +4 -0
- package/CHANGELOG.md +0 -1431
- package/eslint.config.mjs +0 -50
- package/scripts/holidays2json.cjs +0 -197
- package/tsconfig.json +0 -19
- package/tsconfig.test.json +0 -11
package/eslint.config.mjs
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { defineConfig, globalIgnores } from 'eslint/config'
|
|
2
|
-
import js from '@eslint/js'
|
|
3
|
-
import globals from 'globals'
|
|
4
|
-
import { configs as ymlConfigs } from 'eslint-plugin-yml'
|
|
5
|
-
|
|
6
|
-
export default defineConfig([
|
|
7
|
-
globalIgnores([
|
|
8
|
-
'coverage/**',
|
|
9
|
-
'dist/**',
|
|
10
|
-
'lib/**',
|
|
11
|
-
'src/data.js',
|
|
12
|
-
'pnpm-lock.yaml'
|
|
13
|
-
]),
|
|
14
|
-
{
|
|
15
|
-
files: ['**/*.js', '**/*.mjs'],
|
|
16
|
-
languageOptions: {
|
|
17
|
-
globals: {
|
|
18
|
-
...globals.browser,
|
|
19
|
-
...globals.node,
|
|
20
|
-
...globals.mocha
|
|
21
|
-
},
|
|
22
|
-
ecmaVersion: 'latest',
|
|
23
|
-
sourceType: 'module'
|
|
24
|
-
},
|
|
25
|
-
extends: [
|
|
26
|
-
js.configs.recommended
|
|
27
|
-
]
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
files: ['**/*.cjs'],
|
|
31
|
-
languageOptions: {
|
|
32
|
-
globals: {
|
|
33
|
-
...globals.node,
|
|
34
|
-
...globals.mocha
|
|
35
|
-
},
|
|
36
|
-
ecmaVersion: 'latest',
|
|
37
|
-
sourceType: 'commonjs'
|
|
38
|
-
},
|
|
39
|
-
extends: [
|
|
40
|
-
js.configs.recommended
|
|
41
|
-
]
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
files: ['**/*.yaml', '**/*.yml'],
|
|
45
|
-
extends: [ymlConfigs['flat/standard']],
|
|
46
|
-
rules: {
|
|
47
|
-
'yml/plain-scalar': 'off'
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
])
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
'use strict'
|
|
4
|
-
|
|
5
|
-
const fs = require('fs')
|
|
6
|
-
const path = require('path')
|
|
7
|
-
const resolve = path.resolve
|
|
8
|
-
const jsyaml = require('js-yaml')
|
|
9
|
-
const PrePin = require('prepin')
|
|
10
|
-
const { pick: _pick, omit: _omit } = require('lodash')
|
|
11
|
-
|
|
12
|
-
const REGEX = /^([A-Z]+)\.yaml$/
|
|
13
|
-
|
|
14
|
-
const dirParser = path.dirname(require.resolve('date-holidays-parser'))
|
|
15
|
-
|
|
16
|
-
const config = {
|
|
17
|
-
dirname: resolve(__dirname, '..', 'data'),
|
|
18
|
-
countries: resolve(__dirname, '..', 'data', 'countries'),
|
|
19
|
-
factories: [
|
|
20
|
-
resolve(dirParser, '..', 'src', 'CalEventFactory.js'),
|
|
21
|
-
resolve(dirParser, '..', 'lib', 'CalEventFactory.cjs')
|
|
22
|
-
]
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function Holidays2json (opts) {
|
|
26
|
-
this.opts = opts || {}
|
|
27
|
-
this.list = this.opts.list || []
|
|
28
|
-
}
|
|
29
|
-
Holidays2json.prototype = {
|
|
30
|
-
/**
|
|
31
|
-
* get list of supported countries from directory
|
|
32
|
-
*/
|
|
33
|
-
getList: function () {
|
|
34
|
-
let list = fs.readdirSync(config.countries)
|
|
35
|
-
list = list
|
|
36
|
-
.map((file) => {
|
|
37
|
-
if (REGEX.test(file)) {
|
|
38
|
-
return file.replace(REGEX, '$1')
|
|
39
|
-
} else {
|
|
40
|
-
return undefined
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
.filter(function (file) {
|
|
44
|
-
return file
|
|
45
|
-
})
|
|
46
|
-
.sort()
|
|
47
|
-
this.list = list
|
|
48
|
-
return this
|
|
49
|
-
},
|
|
50
|
-
/**
|
|
51
|
-
* load a single yaml file
|
|
52
|
-
*/
|
|
53
|
-
load: function (cc, filename) {
|
|
54
|
-
filename = filename || resolve(config.countries, cc + '.yaml')
|
|
55
|
-
const data = fs.readFileSync(filename, 'utf8')
|
|
56
|
-
const obj = jsyaml.load(data)
|
|
57
|
-
return obj
|
|
58
|
-
},
|
|
59
|
-
/**
|
|
60
|
-
* build `holidays.json file`
|
|
61
|
-
*/
|
|
62
|
-
build: function () {
|
|
63
|
-
const obj = this.load('0')
|
|
64
|
-
obj.holidays = {}
|
|
65
|
-
this.list.forEach(function (cc) {
|
|
66
|
-
Object.assign(obj.holidays, this.load(cc).holidays)
|
|
67
|
-
}.bind(this))
|
|
68
|
-
Object.assign(obj, this.load(null, resolve(config.dirname, 'names.yaml')))
|
|
69
|
-
|
|
70
|
-
if (this.opts.pick) {
|
|
71
|
-
obj.holidays = _pick(obj.holidays, this.opts.pick)
|
|
72
|
-
} else if (this.opts.omit) {
|
|
73
|
-
obj.holidays = _omit(obj.holidays, this.opts.omit)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
obj.version = new Date().toISOString().replace(/^(.*)T.*$/, '$1')
|
|
77
|
-
this.holidays = obj
|
|
78
|
-
|
|
79
|
-
if (this.opts.min) this.prepin()
|
|
80
|
-
|
|
81
|
-
return this
|
|
82
|
-
},
|
|
83
|
-
/**
|
|
84
|
-
* save holidays
|
|
85
|
-
*/
|
|
86
|
-
save: function () {
|
|
87
|
-
const json = JSON.stringify(this.holidays, null, 2) + '\n'
|
|
88
|
-
fs.writeFileSync(resolve(config.dirname, 'holidays.json'), json, 'utf8')
|
|
89
|
-
fs.writeFileSync(resolve(__dirname, '..', 'src', 'data.js'), 'export const data = ' + json, 'utf8')
|
|
90
|
-
if (fs.existsSync(resolve(__dirname, '..', 'lib'))) {
|
|
91
|
-
fs.writeFileSync(resolve(__dirname, '..', 'lib', 'data.cjs'), 'exports.data = ' + json, 'utf8')
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
/**
|
|
95
|
-
* modify the factories to require only the minimum required packages
|
|
96
|
-
*/
|
|
97
|
-
prepin: function () {
|
|
98
|
-
// reduce final build size
|
|
99
|
-
const macros = dive(this.holidays)
|
|
100
|
-
config.factories.forEach(function (fa) {
|
|
101
|
-
new PrePin({ macros, input: fa, output: fa }).proc().catch(function (e) {
|
|
102
|
-
console.error(e)
|
|
103
|
-
})
|
|
104
|
-
})
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
module.exports = Holidays2json
|
|
108
|
-
|
|
109
|
-
if (module === require.main) {
|
|
110
|
-
const args = process.argv.splice(2)
|
|
111
|
-
|
|
112
|
-
const getOption = function (option) {
|
|
113
|
-
const i = args.indexOf(option)
|
|
114
|
-
if (i !== -1) {
|
|
115
|
-
const list = (args[i + 1] || '').toUpperCase().split(',').sort()
|
|
116
|
-
if (list && list.length) return list
|
|
117
|
-
return true
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (getOption('-h') || getOption('--help')) {
|
|
122
|
-
console.log([
|
|
123
|
-
'',
|
|
124
|
-
'holidays2json [options]',
|
|
125
|
-
'',
|
|
126
|
-
'translate holidays.yaml data to json',
|
|
127
|
-
'',
|
|
128
|
-
'-p|--pick comma separated list of countries to pick',
|
|
129
|
-
' from holidays.json file',
|
|
130
|
-
'-o|--omit comma separated list of countries to omit',
|
|
131
|
-
' from holidays.json file',
|
|
132
|
-
'-m|--min minimize the package dependencies - e.g. if using webpack or',
|
|
133
|
-
' browserify',
|
|
134
|
-
'',
|
|
135
|
-
'NOTE: There are some countries which depend on data of others which',
|
|
136
|
-
' might render the file useless. e.g. "GU" requires "US", so try',
|
|
137
|
-
' to pick or omit both.',
|
|
138
|
-
'',
|
|
139
|
-
'Use in your build process in package.json "scripts" section.',
|
|
140
|
-
' "build" : "holidays2json -p US,CA,GU"',
|
|
141
|
-
'and run then with `npm run build`',
|
|
142
|
-
''
|
|
143
|
-
].join('\n '))
|
|
144
|
-
process.exit(0)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const opts = {
|
|
148
|
-
pick: getOption('--pick') || getOption('-p'),
|
|
149
|
-
omit: getOption('--omit') || getOption('-o'),
|
|
150
|
-
min: getOption('--min') || getOption('-m')
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
new Holidays2json(opts).getList().build().save()
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* searches for `days` to obtain macros for prepin
|
|
158
|
-
*/
|
|
159
|
-
function dive (data, macros) {
|
|
160
|
-
macros = macros || {
|
|
161
|
-
nobengali: true,
|
|
162
|
-
nochinese: true,
|
|
163
|
-
noequinox: true,
|
|
164
|
-
nohebrew: true,
|
|
165
|
-
noislamic: true,
|
|
166
|
-
nojalaali: true,
|
|
167
|
-
nojulian: true
|
|
168
|
-
}
|
|
169
|
-
switch (toString.call(data)) {
|
|
170
|
-
case '[object Object]':
|
|
171
|
-
Object.keys(data).forEach(function (key) {
|
|
172
|
-
if (key === 'days') {
|
|
173
|
-
Object.keys(data[key]).forEach(function (key) {
|
|
174
|
-
if (/\b(Muharram|Safar|Rabi al-awwal|Rabi al-thani|Jumada al-awwal|Jumada al-thani|Rajab|Shaban|Ramadan|Shawwal|Dhu al-Qidah|Dhu al-Hijjah)\b/.test(key)) {
|
|
175
|
-
delete macros.noislamic
|
|
176
|
-
} else if (/\b(julian)\b/.test(key)) {
|
|
177
|
-
delete macros.nojulian
|
|
178
|
-
} else if (/\b(chinese|vietnamese|korean)\b/.test(key)) {
|
|
179
|
-
delete macros.nochinese
|
|
180
|
-
} else if (/\b(bengali-revised)\b/.test(key)) {
|
|
181
|
-
delete macros.nobengali
|
|
182
|
-
} else if (/\b(equinox|solstice)\b/.test(key)) {
|
|
183
|
-
delete macros.noequinox
|
|
184
|
-
} else if (/\b(Nisan|Iyyar|Sivan|Tamuz|Av|Elul|Tishrei|Cheshvan|Kislev|Tevet|Shvat|Adar)\b/.test(key)) {
|
|
185
|
-
delete macros.nohebrew
|
|
186
|
-
} else if (/\b(Farvardin|Ordibehesht|Khordad|Tir|Mordad|Shahrivar|Mehr|Aban|Azar|Dey|Bahman|Esfand)\b/.test(key)) {
|
|
187
|
-
delete macros.nojalaali
|
|
188
|
-
}
|
|
189
|
-
})
|
|
190
|
-
} else {
|
|
191
|
-
dive(data[key], macros)
|
|
192
|
-
}
|
|
193
|
-
})
|
|
194
|
-
break
|
|
195
|
-
}
|
|
196
|
-
return macros
|
|
197
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"allowJs": true,
|
|
4
|
-
"checkJs": true,
|
|
5
|
-
"forceConsistentCasingInFileNames": true,
|
|
6
|
-
"module": "NodeNext",
|
|
7
|
-
"moduleResolution": "NodeNext",
|
|
8
|
-
"declaration": true,
|
|
9
|
-
"declarationDir": "./types",
|
|
10
|
-
"emitDeclarationOnly": true,
|
|
11
|
-
"rootDir": "./src",
|
|
12
|
-
"skipLibCheck": true,
|
|
13
|
-
"strict": false,
|
|
14
|
-
"target": "ESNext",
|
|
15
|
-
"types": ["node"]
|
|
16
|
-
},
|
|
17
|
-
"include": ["src/**/*.js", "src/**/*.d.ts"],
|
|
18
|
-
"exclude": ["src/data.js"]
|
|
19
|
-
}
|