Skip to content

Commit

Permalink
prettier --write '**/*.js'
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Mar 24, 2020
1 parent c5ef5d7 commit dd570e3
Show file tree
Hide file tree
Showing 32 changed files with 148 additions and 148 deletions.
4 changes: 2 additions & 2 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ const rbnfNameByCssName = {
armenian: 'renderArmenianLower',
hebrew: 'renderHebrew',
ethiopic: 'renderEthiopic',
tamil: 'renderTamil'
tamil: 'renderTamil',
};

for (const [cssName, rbnfName] of Object.entries(rbnfNameByCssName)) {
const renderers = cldr.extractRbnfFunctionByType('root', rbnfName);

const className = _.camelCase(cssName).replace(/^[a-z]/, $0 =>
const className = _.camelCase(cssName).replace(/^[a-z]/, ($0) =>
$0.toUpperCase()
);

Expand Down
4 changes: 2 additions & 2 deletions lib/getCounterCharacters.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function isWithinRange(value, range) {
function getCounterCharacters(counterStyle, counterStyles, counterValue) {
if (Array.isArray(counterValue)) {
return counterValue
.map(counterValue =>
.map((counterValue) =>
getCounterCharacters(counterStyle, counterStyles, counterValue)
)
.join('');
Expand Down Expand Up @@ -133,7 +133,7 @@ function getCounterCharacters(counterStyle, counterStyles, counterValue) {
}
tokens.push({
value: parseInt(value, 10),
text
text,
});
}
);
Expand Down
6 changes: 3 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function create(name, options) {
if (options) {
options = {
...name,
...options
...options,
};
} else {
options = name;
Expand All @@ -22,7 +22,7 @@ function create(name, options) {

module.exports = create;

create.supports = create.isSupported = name => {
create.supports = create.isSupported = (name) => {
if (typeof name === 'object' && name) {
name = name.system;
}
Expand Down Expand Up @@ -56,7 +56,7 @@ for (const Class of [
require('./renderers/UpperAlpha'),
require('./renderers/UpperLatin'),
require('./renderers/UpperGreek'),
require('./renderers/UpperRoman')
require('./renderers/UpperRoman'),
]) {
if (Class.cssName) {
CounterClassByType[Class.cssName] = Class;
Expand Down
2 changes: 1 addition & 1 deletion lib/renderers/Additive.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = class Additive extends CounterStyle {
}
tokens.push({
value: parseInt(value, 10),
text
text,
});
}
);
Expand Down
2 changes: 1 addition & 1 deletion lib/renderers/CounterStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = class CounterStyle {
pad,
range,
fallback,
symbols
symbols,
} = {}) {
this.prefix = prefix;
this.suffix = suffix;
Expand Down
2 changes: 1 addition & 1 deletion lib/renderers/LowerAlpha.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = class LowerAlpha extends Alphabetic {

constructor() {
super({
symbols: 'a b c d e f g h i j k l m n o p q r s t u v w x y z'
symbols: 'a b c d e f g h i j k l m n o p q r s t u v w x y z',
});
}
};
2 changes: 1 addition & 1 deletion lib/renderers/LowerLatin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = class LowerLatin extends Alphabetic {

constructor() {
super({
symbols: 'a b c d e f g h i j k l m n o p q r s t u v w x y z'
symbols: 'a b c d e f g h i j k l m n o p q r s t u v w x y z',
});
}
};
2 changes: 1 addition & 1 deletion lib/renderers/UpperAlpha.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = class LowerLatin extends Alphabetic {

constructor() {
super({
symbols: 'A B C D E F G H I J K L M N O P Q R S T U V W Z Y Z'
symbols: 'A B C D E F G H I J K L M N O P Q R S T U V W Z Y Z',
});
}
};
2 changes: 1 addition & 1 deletion lib/renderers/UpperLatin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = class LowerLatin extends Alphabetic {

constructor() {
super({
symbols: 'A B C D E F G H I J K L M N O P Q R S T U V W Z Y Z'
symbols: 'A B C D E F G H I J K L M N O P Q R S T U V W Z Y Z',
});
}
};
40 changes: 20 additions & 20 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,82 +1,82 @@
const counteraction = require('../lib/index');
const expect = require('unexpected');

describe('index', function() {
it('should create a counter renderer by name', function() {
describe('index', function () {
it('should create a counter renderer by name', function () {
const renderer = counteraction('lower-roman');
expect(renderer.render(12), 'to equal', 'xii');
});

it('should return undefined if an unknown name is passed', function() {
it('should return undefined if an unknown name is passed', function () {
const renderer = counteraction('foo');
expect(renderer, 'to be undefined');
});

it('should return undefined if undefined is passed as the name', function() {
it('should return undefined if undefined is passed as the name', function () {
const renderer = counteraction(undefined);
expect(renderer, 'to be undefined');
});

it('should create a @counter-style renderer by an options object', function() {
it('should create a @counter-style renderer by an options object', function () {
const renderer = counteraction({
system: 'fixed',
symbols: ['A', 'B']
symbols: ['A', 'B'],
});
expect(renderer.render(1), 'to equal', 'A');
expect(renderer.render(2), 'to equal', 'B');
});

it('should create a @counter-style renderer by a system string and an options object', function() {
it('should create a @counter-style renderer by a system string and an options object', function () {
const renderer = counteraction('fixed', {
symbols: ['A', 'B']
symbols: ['A', 'B'],
});
expect(renderer.render(2), 'to equal', 'B');
});

it('should create a @counter-style renderer by an object of props and an options object', function() {
it('should create a @counter-style renderer by an object of props and an options object', function () {
const renderer = counteraction(
{
system: 'fixed',
symbols: ['A', 'B']
symbols: ['A', 'B'],
},
{
fallback: 'disc'
fallback: 'disc',
}
);
expect(renderer.render(1), 'to equal', 'A');
expect(renderer.render(2), 'to equal', 'B');
expect(renderer.render(3), 'to equal', '•');
});

describe('supports', function() {
describe('when given a name', function() {
it('should return true for a supported list-style-type', function() {
describe('supports', function () {
describe('when given a name', function () {
it('should return true for a supported list-style-type', function () {
expect(counteraction.supports('disc'), 'to be true');
});

it('should return true for a supported @counter-style system', function() {
it('should return true for a supported @counter-style system', function () {
expect(counteraction.supports('fixed'), 'to be true');
});

it('should return false for a unsupported type', function() {
it('should return false for a unsupported type', function () {
expect(counteraction.supports('foo'), 'to be false');
});
});

describe('when given an object with a system property', function() {
it('should return true for a supported @counter-style system', function() {
describe('when given an object with a system property', function () {
it('should return true for a supported @counter-style system', function () {
expect(
counteraction.supports({ system: 'fixed', symbols: ['A'] }),
'to be true'
);
});

it('should return false for a supported @counter-style system', function() {
it('should return false for a supported @counter-style system', function () {
expect(counteraction.supports({ system: 'foo' }), 'to be false');
});
});

it('should return true for a unsupported type', function() {
it('should return true for a unsupported type', function () {
expect(counteraction.supports('foo'), 'to be false');
});
});
Expand Down
18 changes: 9 additions & 9 deletions test/renderers/Additive.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
const Additive = require('../../lib/renderers/Additive');
const expect = require('unexpected');

describe('Additive', function() {
it('should have a cssName of additive', function() {
describe('Additive', function () {
it('should have a cssName of additive', function () {
expect(Additive, 'to have property', 'cssName', 'additive');
});

it('should fall back', function() {
it('should fall back', function () {
const additive = new Additive({ symbols: 'A B' });

expect(additive.render(-1), 'to equal', '-1');
expect(additive.render(0), 'to equal', '0');
});

it('should render the values correctly', function() {
it('should render the values correctly', function () {
const additive = new Additive({
range: '1 3999',
'additive-symbols':
'1000 M, 900 CM, 500 D, 400 CD, 100 C, 90 XC, 50 L, 40 XL, 10 X, 9 IX, 5 V, 4 IV, 1 I'
'1000 M, 900 CM, 500 D, 400 CD, 100 C, 90 XC, 50 L, 40 XL, 10 X, 9 IX, 5 V, 4 IV, 1 I',
});
expect(additive.render(123), 'to equal', 'CXXIII');
});

it('should support quoted strings', function() {
it('should support quoted strings', function () {
const additive = new Additive({
range: '1 3999',
'additive-symbols':
"100 'C,foo', 90 XC, 50 L, 40 XL, 10 X, 9 IX, 5 V, 4 IV, 1 I"
"100 'C,foo', 90 XC, 50 L, 40 XL, 10 X, 9 IX, 5 V, 4 IV, 1 I",
});
expect(additive.render(123), 'to equal', 'C,fooXXIII');
});

it('should not mind if the symbols are not defined in order of decreasing value', function() {
it('should not mind if the symbols are not defined in order of decreasing value', function () {
const additive = new Additive({
range: '1 3999',
'additive-symbols':
'1000 M, 900 CM, 500 D, 400 CD, 90 XC, 50 L, 40 XL, 10 X, 9 IX, 5 V, 4 IV, 1 I, 100 C'
'1000 M, 900 CM, 500 D, 400 CD, 90 XC, 50 L, 40 XL, 10 X, 9 IX, 5 V, 4 IV, 1 I, 100 C',
});

expect(additive.render(123), 'to equal', 'CXXIII');
Expand Down
14 changes: 7 additions & 7 deletions test/renderers/Alphabetic.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const Alphabetic = require('../../lib/renderers/Alphabetic');
const expect = require('unexpected');

describe('Alphabetic', function() {
it('should have a cssName of alphabetic', function() {
describe('Alphabetic', function () {
it('should have a cssName of alphabetic', function () {
expect(Alphabetic, 'to have property', 'cssName', 'alphabetic');
});

it('should wrap around and interpret the symbols as digits', function() {
it('should wrap around and interpret the symbols as digits', function () {
const alphabetic = new Alphabetic({ symbols: 'A B' });

expect(alphabetic.render(1), 'to equal', 'A');
Expand All @@ -16,18 +16,18 @@ describe('Alphabetic', function() {
expect(alphabetic.render(5), 'to equal', 'BA');
});

it('should fall back', function() {
it('should fall back', function () {
const alphabetic = new Alphabetic({ symbols: 'A B' });

expect(alphabetic.render(-1), 'to equal', '-1');
expect(alphabetic.render(0), 'to equal', '0');
});

describe('with a range', function() {
it('should fall back when rendering values outside of the range', function() {
describe('with a range', function () {
it('should fall back when rendering values outside of the range', function () {
const alphabetic = new Alphabetic({
symbols: 'A B C D E F G H I J K L',
range: '1 2, 4 5, 7 infinite'
range: '1 2, 4 5, 7 infinite',
});

expect(alphabetic.render(1), 'to equal', 'A');
Expand Down
10 changes: 5 additions & 5 deletions test/renderers/Armenian.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const Armenian = require('../../lib/renderers/Armenian');
const expect = require('unexpected');

describe('Armenian', function() {
it('should have a cssName of armenian', function() {
describe('Armenian', function () {
it('should have a cssName of armenian', function () {
expect(Armenian, 'to have property', 'cssName', 'armenian');
});

it('should render a small number', function() {
it('should render a small number', function () {
expect(new Armenian().render(12), 'to equal', 'ժբ');
});

it('should render a big number', function() {
it('should render a big number', function () {
expect(new Armenian().render(1234), 'to equal', 'ռմլդ');
});

it('should render a negative number', function() {
it('should render a negative number', function () {
expect(new Armenian().render(-12), 'to equal', '−ժբ');
});
});
12 changes: 6 additions & 6 deletions test/renderers/CounterStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@ const Fixed = require('../../lib/renderers/Fixed');
const Disc = require('../../lib/renderers/Disc');
const expect = require('unexpected');

describe('CounterStyle', function() {
describe('with a lazy fallback passed as a function', function() {
it('should support a list-style-type being returned', function() {
describe('CounterStyle', function () {
describe('with a lazy fallback passed as a function', function () {
it('should support a list-style-type being returned', function () {
// Test via subclass
const fixed = new Fixed({
symbols: 'A B',
fallback() {
return 'disc';
}
},
});

expect(fixed.render(1), 'to equal', 'A');
expect(fixed.render(2), 'to equal', 'B');
expect(fixed.render(3), 'to equal', '•');
});

it('should support a renderer being returned', function() {
it('should support a renderer being returned', function () {
// Test via subclass
const fixed = new Fixed({
symbols: 'A B',
fallback() {
return new Disc();
}
},
});

expect(fixed.render(1), 'to equal', 'A');
Expand Down
8 changes: 4 additions & 4 deletions test/renderers/Cyclic.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const Cyclic = require('../../lib/renderers/Cyclic');
const expect = require('unexpected');

describe('Cyclic', function() {
it('should have a cssName of cyclic', function() {
describe('Cyclic', function () {
it('should have a cssName of cyclic', function () {
expect(Cyclic, 'to have property', 'cssName', 'cyclic');
});

it('should wrap around', function() {
it('should wrap around', function () {
const cyclic = new Cyclic({ symbols: 'A B C D' });

expect(cyclic.render(1), 'to equal', 'A');
expect(cyclic.render(3), 'to equal', 'C');
expect(cyclic.render(5), 'to equal', 'A');
});

it('should fall back', function() {
it('should fall back', function () {
const cyclic = new Cyclic({ symbols: 'A B' });

expect(cyclic.render(-1), 'to equal', '-1');
Expand Down
Loading

0 comments on commit dd570e3

Please sign in to comment.