chinese-year-e 1.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/.babelrc +3 -0
- package/.travis.yml +6 -0
- package/LICENSE +21 -0
- package/README.md +26 -0
- package/index.js +19 -0
- package/index.test.js +27 -0
- package/lib/index.js +19 -0
- package/lib/index.test.js +33 -0
- package/package.json +43 -0
package/.babelrc
ADDED
package/.travis.yml
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Song Wang
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# chinese-year [](https://travis-ci.org/wangsongiam/chinese-year)
|
|
2
|
+
> get the zodiac animal name of a certain year
|
|
3
|
+
|
|
4
|
+
## Install
|
|
5
|
+
```
|
|
6
|
+
npm install --save chinese-year-e
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
```js
|
|
11
|
+
const chineseYear = require('chinese-year-e')
|
|
12
|
+
chineseYear.years
|
|
13
|
+
//=> ['Rat', 'Ox', ...]
|
|
14
|
+
|
|
15
|
+
chineseYear.getAnimal(2000)
|
|
16
|
+
//=> 'Dragon'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## API
|
|
20
|
+
### .getAnimal(year: number):string
|
|
21
|
+
### .getAnimale(year: number):string
|
|
22
|
+
### .year:array
|
|
23
|
+
get zodiac animal name of a year number with emoji
|
|
24
|
+
|
|
25
|
+
## License
|
|
26
|
+
MIT © [Song Wang](https://songwang.io)
|
package/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const years = ['Rat', 'Ox', 'Tiger', 'Rabbit', 'Dragon', 'Snake', 'Horse', 'Sheep', 'Monkey', 'Rooster', 'Dog', 'Pig'];
|
|
2
|
+
const yearse=['🐀', '🐂','🐅','🐇','🐉','🐍','🐎','🐑','🐒','🐓','🐕','🐖'];
|
|
3
|
+
|
|
4
|
+
exports.years = years
|
|
5
|
+
|
|
6
|
+
exports.getAnimal = num => {
|
|
7
|
+
const ind = num % 12;
|
|
8
|
+
let name =years[ind];
|
|
9
|
+
name+= ' '+yearse[ind];
|
|
10
|
+
if (!name) throw new Error(`Opps, error`)
|
|
11
|
+
return name
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.getAnimale = num => {
|
|
15
|
+
const ind = num % 12;
|
|
16
|
+
let name =yearse[ind];
|
|
17
|
+
if (!name) throw new Error(`Opps, error`)
|
|
18
|
+
return name
|
|
19
|
+
}
|
package/index.test.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import chineseYears from '.'
|
|
2
|
+
|
|
3
|
+
test('get the first animal', ()=> {
|
|
4
|
+
expect(chineseYears.years[0]).toBe('Rat 🐀')
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
test('get the secons animal', ()=> {
|
|
9
|
+
expect(chineseYears.years[1]).toBe('Ox 🐂')
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
test('get the last animal', ()=> {
|
|
13
|
+
expect(chineseYears.years[chineseYears.years.length-1]).toBe('Pig 🐖')
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
test(`get 2000's Dragon`, ()=> {
|
|
18
|
+
expect(chineseYears.getAnimal(2000)).toBe('Dragon 🐉')
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
test(`get 2016's Monkey`, ()=> {
|
|
22
|
+
expect(chineseYears.getAnimal(2016)).toBe('Monkey 🐒')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
test(`get 2012's Monkey`, ()=> {
|
|
26
|
+
expect(chineseYears.getAnimal(2012)).toBe('Dragon 🐉')
|
|
27
|
+
})
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var years = ['Rat', 'Ox', 'Tiger', 'Rabbit', 'Dragon', 'Snake', 'Horse', 'Sheep', 'Monkey', 'Rooster', 'Dog', 'Pig'];
|
|
4
|
+
var yearse=['🐀', '🐂','🐅','🐇','🐉','🐍','🐎','🐑','🐒','🐓','🐕','🐖'];
|
|
5
|
+
exports.years = years;
|
|
6
|
+
|
|
7
|
+
exports.getAnimal = function (num) {
|
|
8
|
+
var ind = num % 12;
|
|
9
|
+
var name = years[ind];
|
|
10
|
+
if (!name) throw new Error('Opps, error');
|
|
11
|
+
return name;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.getAnimale = function (num) {
|
|
15
|
+
var ind = num % 12;
|
|
16
|
+
var name = yearse[ind];
|
|
17
|
+
if (!name) throw new Error('Opps, error');
|
|
18
|
+
return name;
|
|
19
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _ = require('.');
|
|
4
|
+
|
|
5
|
+
var _2 = _interopRequireDefault(_);
|
|
6
|
+
|
|
7
|
+
function _interopRequireDefault(obj) {
|
|
8
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
test('get the first animal', function () {
|
|
12
|
+
expect(_2.default.years[0]).toBe('Rat 🐀');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('get the secons animal', function () {
|
|
16
|
+
expect(_2.default.years[1]).toBe('Ox 🐂');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('get the last animal', function () {
|
|
20
|
+
expect(_2.default.years[_2.default.years.length - 1]).toBe('Pig 🐖');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('get 2000\'s Dragon', function () {
|
|
24
|
+
expect(_2.default.getAnimal(2000)).toBe('Dragon 🐉');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('get 2016\'s Monkey', function () {
|
|
28
|
+
expect(_2.default.getAnimal(2016)).toBe('Monkey 🐒');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('get 2012\'s Monkey', function () {
|
|
32
|
+
expect(_2.default.getAnimal(2012)).toBe('Dragon 🐉');
|
|
33
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "chinese-year-e",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "get the zodiac animal name of a year with emoji",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "jest lib",
|
|
8
|
+
"build": "babel . --out-dir lib --ignore node_modules lib"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/thakkaha/chinese-year-e.git"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"chinese",
|
|
16
|
+
"year",
|
|
17
|
+
"zodiac",
|
|
18
|
+
"animals",
|
|
19
|
+
"rat",
|
|
20
|
+
"ox",
|
|
21
|
+
"tiger",
|
|
22
|
+
"rabbit",
|
|
23
|
+
"dragon",
|
|
24
|
+
"snake",
|
|
25
|
+
"horse",
|
|
26
|
+
"sheep",
|
|
27
|
+
"monkey",
|
|
28
|
+
"rooster",
|
|
29
|
+
"dog",
|
|
30
|
+
"pig"
|
|
31
|
+
],
|
|
32
|
+
"author": "Harsh Thakkar",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/thakkaha/chinese-year-e/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/thakkaha/chinese-year-e#readme",
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"babel-cli": "^6.24.1",
|
|
40
|
+
"babel-preset-env": "^1.6.0",
|
|
41
|
+
"jest": "^20.0.4"
|
|
42
|
+
}
|
|
43
|
+
}
|