diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c1870cf..3b8aa86 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/index.js b/index.js index 9cf020c..9e4686a 100644 --- a/index.js +++ b/index.js @@ -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; @@ -17,4 +17,4 @@ module.exports = function (max, min, useGzip = false) { } return returnValue; -}; +} diff --git a/license b/license index 67dd2cf..fa7ceba 100644 --- a/license +++ b/license @@ -1,4 +1,4 @@ -qMIT License +MIT License Copyright (c) Sindre Sorhus (https://sindresorhus.com) diff --git a/package.json b/package.json index 1e20ee4..a20316b 100644 --- a/package.json +++ b/package.json @@ -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" + } } diff --git a/readme.md b/readme.md index bab0c7e..97f88fc 100644 --- a/readme.md +++ b/readme.md @@ -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};'; diff --git a/test.js b/test.js index 3144844..bfbb5d2 100644 --- a/test.js +++ b/test.js @@ -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};';