Skip to content

Commit

Permalink
build(npm): Upgrade development dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
VovanR committed Apr 23, 2019
1 parent b8c93af commit 49082e6
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 45 deletions.
5 changes: 5 additions & 0 deletions .huskyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"hooks": {
"pre-push": "npm test"
}
}
40 changes: 21 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,30 @@
*/

(function (root, factory) {
/* eslint-disable */
// eslint-disable-next-line no-undef
if (typeof define === 'function' && define.amd) {
// eslint-disable-next-line no-undef
define([], function () {
// eslint-disable-next-line no-return-assign
return (root.ArabicRoman = factory());
});
} else if (typeof module === 'object' && module.exports) {
module.exports = factory();
} else {
root.ArabicRoman = factory();
}
/* eslint-enable */
})(this, function () {
'use strict';

var arabic = [
1000,
900, // hard number
900, // Hard number
500,
400, // hard number
400, // Hard number
100,
90, // hard number
90, // Hard number
50,
40, // hard number
40, // Hard number
12,
11
];
Expand Down Expand Up @@ -55,18 +56,18 @@
];
var roman = [
'\u216F',
'\u216D\u216F', // hard number
'\u216D\u216F', // Hard number
'\u216E',
'\u216D\u216E', // hard number
'\u216D\u216E', // Hard number
'\u216D',
'\u2169\u216D', // hard number
'\u2169\u216D', // Hard number
'\u216C',
'\u2169\u216C', // hard number
'\u2169\u216C', // Hard number
'\u216B',
'\u216A'
];

// from 10 to 1
// From 10 to 1
var i = 11;
while (--i) {
arabic.push(i);
Expand All @@ -76,8 +77,8 @@
var length = roman.length;

/**
* @param {String} source
* @return {String}
* @param {string} source
* @return {string}
*/
function convertRoman(source) {
var result = '';
Expand All @@ -99,8 +100,8 @@

return {
/**
* @param {Number|String} source
* @return {String}
* @param {number|string} source
* @return {string}
*/
toRoman: function (source) {
var result;
Expand All @@ -120,8 +121,8 @@
/**
* Convert arabic nubmer to roman UTF-8 numerals
*
* @param {Number|String} number
* @return {String}
* @param {number|string} number
* @return {string}
*/
arabicToRoman: function (number) {
if (typeof number === 'string') {
Expand All @@ -148,6 +149,7 @@
) {
break;
}

result += roman[i];
number -= currentArabic;
}
Expand All @@ -159,8 +161,8 @@
/**
* Convert simple roman string to roman UTF-8 numerals
*
* @param {String} source
* @return {String}
* @param {string} source
* @return {string}
*/
convertRoman: function (source) {
if (typeof source !== 'string') {
Expand Down
28 changes: 12 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
"node": ">=6"
},
"scripts": {
"prepush": "npm test",
"test": "xo && nyc ava",
"test": "xo --no-esnext && nyc ava",
"release-patch": "mversion patch",
"release-minor": "mversion minor",
"release-major": "mversion major",
"deploy": "gh-pages-deploy"
"deploy": "gh-pages -d example"
},
"main": "index.js",
"keywords": [
Expand All @@ -28,15 +27,16 @@
],
"dependencies": {},
"devDependencies": {
"ava": "^0.14.0",
"conventional-changelog-cli": "^1.1.1",
"coveralls": "^2.11.9",
"cz-conventional-changelog": "^1.1.6",
"husky": "^0.11.4",
"mversion": "^1.10.1",
"nyc": "^6.4.0",
"sinon": "^1.17.3",
"xo": "^0.14.0"
"ava": "^1.4.1",
"conventional-changelog-cli": "^2.0.12",
"coveralls": "^3.0.3",
"cz-conventional-changelog": "^2.1.0",
"gh-pages": "^2.0.1",
"husky": "^1.3.1",
"mversion": "^1.13.0",
"nyc": "^14.0.0",
"sinon": "^7.3.2",
"xo": "^0.24.0"
},
"bugs": {
"url": "https://github.com/VovanR/arabic-roman-convert.js/issues"
Expand All @@ -46,9 +46,5 @@
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"gh-pages-deploy": {
"staticpath": "example",
"noprompt": false
}
}
20 changes: 10 additions & 10 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'ava';
import sinon from 'sinon';
import arabicRoman from './';
import arabicRoman from '.';

const cod = {
I: '\u2160',
Expand All @@ -22,19 +22,19 @@ const cod = {
};

/**
* @return {String}
* @return {string} Unicode string
*/
const charToCode = function () {
function charToCode(...rest) {
let res = '';
const args = arguments;
let i;
for (i = 0; i < args.length; i++) {
res += cod[args[i]];
for (i = 0; i < rest.length; i++) {
res += cod[rest[i]];
}

return res;
};
}

// toRoman
// `toRoman`
test('#toRoman should fire `arabicToRoman` if argument is arabic number', t => {
const spy = sinon.spy(arabicRoman, 'arabicToRoman');

Expand All @@ -59,7 +59,7 @@ test('#toRoman should fire `convertRoman` if argument is simple roman', t => {
spy.restore();
});

// arabicToRoman
// `arabicToRoman`
test('#arabicToRoman should not convert number < 1', t => {
t.is(arabicRoman.arabicToRoman(0), undefined);
t.is(arabicRoman.arabicToRoman(-1), undefined);
Expand Down Expand Up @@ -128,7 +128,7 @@ test('#arabicToRoman should convert hard numbers', t => {
t.is(arabicRoman.arabicToRoman(900), charToCode('C', 'M'));
});

// convertRoman
// `convertRoman`
test('#convertRoman should parse string attributes', t => {
t.is(arabicRoman.convertRoman(3), undefined);
t.is(arabicRoman.convertRoman('asdif'), undefined);
Expand Down

0 comments on commit 49082e6

Please sign in to comment.