Skip to content

Commit c99cc91

Browse files
committed
build: tweaks
1 parent 699a1d6 commit c99cc91

File tree

7 files changed

+36
-31
lines changed

7 files changed

+36
-31
lines changed

.babelrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
[![Dependency status](http://img.shields.io/david/Kikobeats/aspect-ratio.svg?style=flat)](https://david-dm.org/Kikobeats/aspect-ratio)
55
[![Dev Dependencies Status](http://img.shields.io/david/dev/Kikobeats/aspect-ratio.svg?style=flat)](https://david-dm.org/Kikobeats/aspect-ratio#info=devDependencies)
66
[![NPM Status](http://img.shields.io/npm/dm/aspect-ratio.svg?style=flat)](https://www.npmjs.org/package/aspect-ratio)
7-
[![Gittip](http://img.shields.io/gittip/Kikobeats.svg?style=flat)](https://www.gittip.com/Kikobeats/)
87

98
> Get the aspect ratio of a device.
109

package.json

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Get the screen aspect ratio of a device",
44
"homepage": "https://github.com/Kikobeats/aspect-ratio",
55
"version": "2.0.3",
6-
"main": "./lib/index.js",
6+
"main": "src",
77
"bin": {
88
"aspect-ratio": "bin/index.js"
99
},
@@ -12,6 +12,20 @@
1212
"name": "Kiko Beats",
1313
"url": "https://github.com/Kikobeats"
1414
},
15+
"contributors": [
16+
{
17+
"name": "Michael W. Clark",
18+
"email": "michaelwclark@gmail.com"
19+
},
20+
{
21+
"name": "Andrei Vinaga",
22+
"email": "andrei.vinaga@ownzones.com"
23+
},
24+
{
25+
"name": "Trevor Blades",
26+
"email": "tdblades@gmail.com"
27+
}
28+
],
1529
"repository": {
1630
"type": "git",
1731
"url": "git+https://github.com/Kikobeats/aspect-ratio.git"
@@ -29,23 +43,20 @@
2943
"meow": "latest"
3044
},
3145
"devDependencies": {
32-
"babel-cli": "latest",
33-
"babel-preset-env": "latest",
3446
"mocha": "latest",
3547
"should": "latest",
3648
"standard": "latest",
3749
"standard-markdown": "latest"
3850
},
3951
"engines": {
40-
"node": ">=6"
52+
"node": ">=8"
4153
},
4254
"files": [
4355
"bin",
44-
"lib"
56+
"src"
4557
],
4658
"scripts": {
4759
"lint": "standard-markdown && standard",
48-
"prepare": "babel *.js --out-dir lib",
4960
"pretest": "npm run lint",
5061
"test": "mocha"
5162
},

index.js renamed to src/index.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
'use strict'
2-
const { gcd, highestFirst, formatAspectRatio } = require('./utils')
32

4-
module.exports = (height, width, seperator = ':') => {
5-
if (typeof height !== 'number') {
6-
throw new Error(`Invalid height: ${height}`)
7-
}
8-
9-
if (typeof width !== 'number') {
10-
throw new Error(`Invalid width: ${width}`)
11-
}
3+
const { gcd, highestFirst, formatAspectRatio } = require('./util')
124

5+
module.exports = (height, width, seperator = ':') => {
6+
if (typeof height !== 'number') throw new Error(`Invalid height: ${height}`)
7+
if (typeof width !== 'number') throw new Error(`Invalid width: ${width}`)
138
const [h, w] = highestFirst(height, width)
149
const divisor = gcd(h, w)
1510
return formatAspectRatio(h, w, divisor, seperator)

src/util.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const gcd = (a, b) => (b === 0 ? a : gcd(b, a % b))
2+
const highestFirst = (a, b) => (a < b ? [b, a] : [a, b])
3+
const formatAspectRatio = (h, w, divisor, seperator) =>
4+
`${h / divisor}${seperator}${w / divisor}`
5+
6+
module.exports = {
7+
gcd,
8+
highestFirst,
9+
formatAspectRatio
10+
}

test/utils.js renamed to test/util.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { highestFirst, gcd, formatAspectRatio } = require('../utils')
1+
const { highestFirst, gcd, formatAspectRatio } = require('../src/util')
22
const should = require('should')
33

44
describe('highestFirst', () => {
@@ -14,7 +14,10 @@ describe('highestFirst', () => {
1414
})
1515

1616
it('-Infinity,Infinity', () => {
17-
should(highestFirst(-Infinity, Infinity)).containDeepOrdered([Infinity, -Infinity])
17+
should(highestFirst(-Infinity, Infinity)).containDeepOrdered([
18+
Infinity,
19+
-Infinity
20+
])
1821
})
1922
})
2023

utils.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)