Compare commits
No commits in common. "2958a792a4f3e1e0a5363b62b8888dca87b5670a" and "7db1ec710a3e6b347f02ea5b4e05374611107e8b" have entirely different histories.
2958a792a4
...
7db1ec710a
26
package.json
26
package.json
@ -1,18 +1,22 @@
|
||||
{
|
||||
"name": "trimkit",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.2",
|
||||
"description": "Javascript and DOM abstractions for smaller minifiable code",
|
||||
"main": "dist/trimkit.js",
|
||||
"module": "dist/trimkit.js",
|
||||
"main": "lib/index.js",
|
||||
"jsnext:main": "src/index.js",
|
||||
"files": [
|
||||
"dist/"
|
||||
"dist",
|
||||
"lib",
|
||||
"src"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint src",
|
||||
"clean": "rimraf dist",
|
||||
"build:umd": "rollup -c rollup.config.js && uglifyjs -m --screw-ie8 -c -o dist/trimkit.min.js dist/trimkit.js",
|
||||
"build:umd:zip": "npm run build:umd && gzip -c9 dist/trimkit.min.js > dist/trimkit.min.js.gz && gzip -c9 dist/trimkit.min.mjs > dist/trimkit.min.mjs.gz",
|
||||
"build": "npm run build:umd:zip && ls -l dist/",
|
||||
"clean": "rimraf dist lib",
|
||||
"build:lib": "NODE_ENV=production babel src --presets=\"stage-0,es2015\" --out-dir lib",
|
||||
"build:umd": "npm run build:lib && NODE_ENV=production rollup -c",
|
||||
"build:umd:min": "npm run build:umd && uglifyjs -m --screw-ie8 -c -o dist/trimkit.min.js dist/trimkit.js",
|
||||
"build:umd:gzip": "npm run build:umd:min && gzip -c9 dist/trimkit.min.js > dist/trimkit.min.js.gz",
|
||||
"build": "npm run build:umd:gzip && ls -l dist/",
|
||||
"prepublish": "npm run clean && npm run build"
|
||||
},
|
||||
"repository": {
|
||||
@ -36,10 +40,10 @@
|
||||
"babel-preset-es2015-rollup": "3.0.0",
|
||||
"babel-preset-stage-0": "6.16.0",
|
||||
"eslint": "3.2.0",
|
||||
"eslint-plugin-flowtype": "2.29.1",
|
||||
"rimraf": "2.5.4",
|
||||
"rollup": "0.66.6",
|
||||
"rollup-plugin-babel": "2.7.1",
|
||||
"rollup-plugin-esmin": "0.1.3",
|
||||
"uglify-es": "3.3.9"
|
||||
"rollup-plugin-json": "2.1.0",
|
||||
"uglifyjs": "2.4.10"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,44 +1,10 @@
|
||||
import esmin from 'rollup-plugin-esmin';
|
||||
import babel from 'rollup-plugin-babel';
|
||||
import pkg from './package.json';
|
||||
import json from 'rollup-plugin-json';
|
||||
|
||||
const config = {
|
||||
input: 'src/index.js',
|
||||
output: {
|
||||
file: pkg.module,
|
||||
format: 'es'
|
||||
}
|
||||
};
|
||||
|
||||
export default [
|
||||
// trimkit.mjs
|
||||
config,
|
||||
|
||||
// trimkit.min.mjs
|
||||
{
|
||||
...config,
|
||||
output: {
|
||||
...config.output,
|
||||
file: 'dist/trimkit.min.mjs'
|
||||
},
|
||||
plugins: [ esmin({
|
||||
overrides: {
|
||||
sourceType: 'module'
|
||||
}
|
||||
}) ]
|
||||
},
|
||||
|
||||
// trimkit.js
|
||||
{
|
||||
...config,
|
||||
output: {
|
||||
export default {
|
||||
entry: 'src/index.js',
|
||||
format: 'umd',
|
||||
file: 'dist/trimkit.js',
|
||||
name: 'trimkit'
|
||||
},
|
||||
plugins: [
|
||||
babel({ sourceType: 'module' })
|
||||
]
|
||||
|
||||
}
|
||||
]
|
||||
moduleName: 'Trimkit',
|
||||
plugins: [ json() ],
|
||||
dest: 'dist/trimkit.js'
|
||||
};
|
||||
|
||||
34
src/index.js
34
src/index.js
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2018 Timothy Farrell
|
||||
// Copyright (c) 2016 Timothy Farrell
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@ -48,31 +48,29 @@ export const ObjectKeys = Object.keys;
|
||||
// Size saved after: ceil(20 / 7) = 3 usages
|
||||
export const DOMDocument = self.document;
|
||||
|
||||
const isType = str => obj => typeof obj === 'function';
|
||||
|
||||
// ES5 output A: var c=(function(t){return function a(b){return t===typeof b}})('function');
|
||||
// ES5 output B: var c=a('function');
|
||||
// ES5 output: function a(b){return"function"===typeof b};
|
||||
// Invocation comparison: typeof a==='function' ~~~ a(b)
|
||||
// Size delta per invocation: 21 - 4 = 17 bytes
|
||||
// Size saved after (A): ceil(75 / 17) = 5 usages
|
||||
// Size saved after (B): ceil(20 / 17) = 2 usages
|
||||
export const isFunction = isType('function');
|
||||
// Size saved after: ceil(43 / 17) = 3 usages
|
||||
export function isFunction(obj) {
|
||||
return typeof obj === 'function';
|
||||
}
|
||||
|
||||
// ES5 output A: var c=(function(t){return function a(b){return t===typeof b}})('string');
|
||||
// ES5 output B: var c=a('string');
|
||||
// ES5 output: function a(b){return"string"===typeof b};
|
||||
// Invocation comparison: typeof a==='string' ~~~ a(b)
|
||||
// Size delta per invocation: 19 - 4 = 15 bytes
|
||||
// Size saved after (A): ceil(73 / 15) = 5 usages
|
||||
// Size saved after (B): ceil(18 / 15) = 2 usages
|
||||
export const isString = isType('string');
|
||||
// Size saved after: ceil(41 / 15) = 3 usages
|
||||
export function isString(obj) {
|
||||
return typeof obj === 'string';
|
||||
}
|
||||
|
||||
// ES5 output A: var c=(function(t){return function a(b){return t===typeof b}})('number');
|
||||
// ES5 output B: var c=a('number');
|
||||
// ES5 output: function a(b){return"number"===typeof b};
|
||||
// Invocation comparison: typeof a==='number' ~~~ a(b)
|
||||
// Size delta per invocation: 19 - 4 = 15 bytes
|
||||
// Size saved after (A): ceil(73 / 15) = 5 usages
|
||||
// Size saved after (B): ceil(18 / 15) = 2 usages
|
||||
export const isNumber = isType('number');
|
||||
// Size saved after: ceil(41 / 15) = 3 usages
|
||||
export function isNumber(obj) {
|
||||
return typeof obj === 'number';
|
||||
}
|
||||
|
||||
// ES5 declaration: var a=null;
|
||||
// Invocation comparison: null ~~~ a
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user