1
0
mirror of synced 2025-12-12 16:18:02 +08:00

支持Node.js环境,发布到NPM仓库

This commit is contained in:
6tail
2020-04-30 00:19:00 +08:00
parent e401a4094e
commit 711aa60ddb
5 changed files with 143 additions and 12 deletions

View File

@@ -6,6 +6,8 @@ lunar是一款无第三方依赖的公历(阳历)和农历(阴历、老黄历)
## 示例
### 普通页面
```html
<!DOCTYPE html>
<html>
@@ -23,6 +25,33 @@ lunar是一款无第三方依赖的公历(阳历)和农历(阴历、老黄历)
</html>
```
### npm
npm init
npm install lunar-javascript
//test.js
const {Solar} = require('lunar-javascript')
//const {Solar, Lunar, HolidayUtil} = require('lunar-javascript')
let solar = Solar.fromYmd(1986,5,29);
console.log(solar.toFullString());
console.log(solar.getLunar().toFullString());
node test.js
### Node.js
//test.js
const {Solar} = require('./lunar.js')
//const {Solar, Lunar, HolidayUtil} = require('./lunar.js')
let solar = Solar.fromYmd(1986,5,29);
console.log(solar.toFullString());
console.log(solar.getLunar().toFullString());
node test.js
输出结果:
1986-05-29 00:00:00 星期四 双子座

View File

@@ -6,6 +6,8 @@ lunar is a calendar library for Solar and Chinese Lunar.
## Example
### Normal Page
```html
<!DOCTYPE html>
<html>
@@ -23,6 +25,33 @@ lunar is a calendar library for Solar and Chinese Lunar.
</html>
```
### npm
npm init
npm install lunar-javascript
//test.js
const {Solar} = require('lunar-javascript')
//const {Solar, Lunar, HolidayUtil} = require('lunar-javascript')
let solar = Solar.fromYmd(1986,5,29);
console.log(solar.toFullString());
console.log(solar.getLunar().toFullString());
node test.js
### Node.js
//test.js
const {Solar} = require('./lunar.js')
//const {Solar, Lunar, HolidayUtil} = require('./lunar.js')
let solar = Solar.fromYmd(1986,5,29);
console.log(solar.toFullString());
console.log(solar.getLunar().toFullString());
node test.js
Output:
1986-05-29 00:00:00 星期四 双子座

13
index.js Normal file
View File

@@ -0,0 +1,13 @@
const {Solar, Lunar, SolarWeek, SolarMonth, SolarSeason, SolarHalfYear, SolarUtil, LunarUtil, HolidayUtil} = require('./lunar.js')
module.exports = {
Solar: Solar,
Lunar: Lunar,
SolarWeek: SolarWeek,
SolarMonth: SolarMonth,
SolarSeason: SolarSeason,
SolarHalfYear: SolarHalfYear,
SolarUtil: SolarUtil,
LunarUtil: LunarUtil,
HolidayUtil: HolidayUtil
}

View File

@@ -1,4 +1,15 @@
(function(W){
;(function(root,factory){
if (typeof define==='function'&&define.amd){
define(factory);
}else if(typeof module!='undefined'&&module.exports){
module.exports = factory();
}else{
var o = factory();
for(var i in o){
root[i] = o[i];
}
}
})(this,function(){
var Solar = (function(){
var _int2=function(v){
v = Math.floor(v);
@@ -1639,14 +1650,16 @@
getHolidaysByTarget:function(){return _getHolidaysByTarget(arguments);}
};
})();
W.SolarUtil = SolarUtil;
W.LunarUtil = LunarUtil;
W.Solar = Solar;
W.Lunar = Lunar;
W.SolarWeek = SolarWeek;
W.SolarMonth = SolarMonth;
W.SolarSeason = SolarSeason;
W.SolarHalfYear = SolarHalfYear;
W.SolarYear = SolarYear;
W.HolidayUtil = HolidayUtil;
})(window);
return {
SolarUtil:SolarUtil,
LunarUtil:LunarUtil,
Solar:Solar,
Lunar:Lunar,
SolarWeek:SolarWeek,
SolarMonth:SolarMonth,
SolarSeason:SolarSeason,
SolarHalfYear:SolarHalfYear,
SolarYear:SolarYear,
HolidayUtil:HolidayUtil
};
});

47
package.json Normal file
View File

@@ -0,0 +1,47 @@
{
"name": "lunar-javascript",
"version": "1.0.0",
"description": "lunar is a calendar library for Solar and Chinese Lunar.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/6tail/lunar-javascript.git"
},
"keywords": [
"calendar",
"lunar",
"solar",
"节假日",
"星座",
"儒略日",
"干支",
"生肖",
"节气",
"节日",
"彭祖百忌",
"喜神",
"福神",
"财神",
"阳贵神",
"阴贵神",
"胎神",
"冲煞",
"纳音",
"星宿",
"八字",
"五行",
"十神",
"建除十二值星",
"青龙名堂等十二神",
"黄道黑道日"
],
"author": "6tail",
"license": "MIT",
"bugs": {
"url": "https://github.com/6tail/lunar-javascript/issues"
},
"homepage": "https://github.com/6tail/lunar-javascript"
}