Skip to content

Commit

Permalink
Require Node.js 12 and move to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed May 3, 2021
1 parent 65f914a commit 674baa3
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 57 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
fail-fast: false
matrix:
node-version:
- 16
- 14
- 12
- 10
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict';
const gzipSize = require('gzip-size');
const prettyBytes = require('pretty-bytes');
const chalk = require('chalk');
const figures = require('figures');
import gzipSize from 'gzip-size';
import prettyBytes from 'pretty-bytes';
import chalk from 'chalk';
import figures from 'figures';

const arrow = ' ' + figures.arrowRight + ' ';

const format = size => chalk.green(prettyBytes(size));

module.exports = function (max, min, useGzip = false) {
export default function maxmin(max, min, useGzip = false) {
const maxString = format(typeof max === 'number' ? max : max.length);
const minString = format(typeof min === 'number' ? min : min.length);
let returnValue = maxString + arrow + minString;
Expand All @@ -17,4 +17,4 @@ module.exports = function (max, min, useGzip = false) {
}

return returnValue;
};
}
2 changes: 1 addition & 1 deletion license
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
qMIT License
MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)

Expand Down
88 changes: 45 additions & 43 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,47 @@
{
"name": "maxmin",
"version": "3.0.0",
"description": "Get a pretty output of the original, minified, gzipped size of a string or buffer: 130 B → 91 B → 53 B (gzip)",
"license": "MIT",
"repository": "sindresorhus/maxmin",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"engines": {
"node": ">=10"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"string",
"buffer",
"pretty",
"color",
"gzip",
"minified",
"min",
"max",
"diff",
"difference"
],
"dependencies": {
"chalk": "^4.1.0",
"figures": "^3.2.0",
"gzip-size": "^5.1.1",
"pretty-bytes": "^5.3.0"
},
"devDependencies": {
"ava": "^2.4.0",
"strip-ansi": "^6.0.0",
"xo": "^0.32.0"
}
"name": "maxmin",
"version": "3.0.0",
"description": "Get a pretty output of the original, minified, gzipped size of a string or buffer: 130 B → 91 B → 53 B (gzip)",
"license": "MIT",
"repository": "sindresorhus/maxmin",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=12"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"string",
"buffer",
"pretty",
"color",
"gzip",
"minified",
"min",
"max",
"diff",
"difference"
],
"dependencies": {
"chalk": "^4.1.1",
"figures": "^3.2.0",
"gzip-size": "^6.0.0",
"pretty-bytes": "^5.6.0"
},
"devDependencies": {
"ava": "^3.15.0",
"strip-ansi": "^7.0.0",
"xo": "^0.39.1"
}
}
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
![](screenshot.png)

Useful for logging the difference between original and minified file in e.g. a build-system.
Useful for logging the difference between original and minified file in, for example, a build-system.

## Install

```
$ npm install --save maxmin
$ npm install maxmin
```

## Usage

```js
const maxmin = require('maxmin');
import maxmin from 'maxmin';

const max = 'function smoothRangeRandom(min,max){var num=Math.floor(Math.random()*(max-min+1)+min);return this.prev=num===this.prev?++num:num};';

Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'ava';
import stripAnsi from 'strip-ansi';
import maxmin from '.';
import maxmin from './index.js';

const max = 'function smoothRangeRandom(min,max){var num=Math.floor(Math.random()*(max-min+1)+min);return this.prev=num===this.prev?++num:num};function smoothRangeRandom(min,max){var num=Math.floor(Math.random()*(max-min+1)+min);return this.prev=num===this.prev?++num:num};function smoothRangeRandom(min,max){var num=Math.floor(Math.random()*(max-min+1)+min);return this.prev=num===this.prev?++num:num};';
const min = 'function smoothRangeRandom(b,c){var a=Math.floor(Math.random()*(c-b+1)+b);return this.prev=a===this.prev?++a:a}function smoothRangeRandom(b,c){var a=Math.floor(Math.random()*(c-b+1)+b);return this.prev=a===this.prev?++a:a}function smoothRangeRandom(b,c){var a=Math.floor(Math.random()*(c-b+1)+b);return this.prev=a===this.prev?++a:a};';
Expand Down

0 comments on commit 674baa3

Please sign in to comment.