Skip to content

Commit

Permalink
Creating filesize.partial() for creating a partial application / fu…
Browse files Browse the repository at this point in the history
…nctional programming style, updating dependencies, fixing lint errors, updating README & LICENSE copyright year, updating README to cover `filesize.partial()`
  • Loading branch information
avoidwork committed Jan 19, 2017
1 parent 048976d commit 1ba7b0c
Show file tree
Hide file tree
Showing 12 changed files with 268 additions and 256 deletions.
29 changes: 12 additions & 17 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
{
"parser": "babel-eslint",
"rules": {
"strict": 0
},
"env": {
"browser": true,
"node": true,
"es6": true,
"amd": true
},
"ecmaFeatures": {
"jsx": true,
"jsx": false,
"superInFunctions": false,
"classes": false,
"modules": [2]
},
"rules": {
"arrow-parens": [2, "as-needed"],
"arrow-spacing": [2, {"before": true, "after": true}],
"block-scoped-var": [0],
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
"camelcase": [0],
Expand All @@ -33,9 +31,9 @@
"func-names": [0],
"func-style": [0, "declaration"],
"generator-star-spacing": [2, "after"],
"strict": [2, "always"],
"guard-for-in": [0],
"handle-callback-err": [0],
"indent": ["error", "tab", {"VariableDeclarator": {"var": 1, "let": 1, "const": 1}, "SwitchCase": 1}],
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
"quotes": [2, "double", "avoid-escape"],
"max-depth": [0, 4],
Expand All @@ -46,6 +44,7 @@
"new-parens": [2],
"new-cap": [2, { "capIsNewExceptions": ["ToInteger", "ToObject", "ToPrimitive", "ToUint32"] }],
"newline-after-var": [0],
"newline-before-return": [2],
"no-alert": [2],
"no-array-constructor": [2],
"no-bitwise": [0],
Expand All @@ -64,14 +63,12 @@
"no-duplicate-case": [2],
"no-else-return": [0],
"no-empty": [2],
"no-empty-label": [2],
"no-eq-null": [0],
"no-eval": [2],
"no-ex-assign": [2],
"no-extend-native": [1],
"no-extra-bind": [2],
"no-extra-boolean-cast": [2],
"no-extra-parens": [0],
"no-extra-semi": [1],
"no-empty-character-class": [2],
"no-fallthrough": [2],
Expand All @@ -97,7 +94,7 @@
"no-negated-in-lhs": [2],
"no-nested-ternary": [0],
"no-new": [2],
"no-new-func": [2],
"no-new-func": [0],
"no-new-object": [2],
"no-new-require": [0],
"no-new-wrappers": [2],
Expand All @@ -113,14 +110,13 @@
"no-redeclare": [2],
"no-regex-spaces": [2],
"no-reserved-keys": [0],
"no-restricted-modules": [0],
"no-reno-new-funced-modules": [0],
"no-return-assign": [2],
"no-script-url": [2],
"no-self-compare": [0],
"no-sequences": [2],
"no-shadow": [2],
"no-shadow-restricted-names": [2],
"semi-spacing": [2],
"no-spaced-func": [2],
"no-sparse-arrays": [2],
"no-sync": [0],
Expand All @@ -133,7 +129,7 @@
"no-underscore-dangle": [0],
"no-unreachable": [2],
"no-unused-expressions": [2],
"no-unused-vars": [1, { "vars": "all", "args": "after-used" }],
"no-unused-vars": [2, { "vars": "all", "args": "after-used" }],
"no-use-before-define": [2],
"no-void": [0],
"no-warning-comments": [0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }],
Expand All @@ -148,9 +144,9 @@
"semi": [2],
"semi-spacing": [2, { "before": false, "after": true }],
"sort-vars": [0],
"space-after-keywords": [2, "always"],
"keyword-spacing": [2],
"space-before-function-paren": [2, { "anonymous": "always", "named": "always" }],
"space-before-blocks": [0, "always"],
"space-before-blocks": [2, "always"],
"space-in-brackets": [0, "never", {
"singleValue": true,
"arraysInArrays": false,
Expand All @@ -161,10 +157,9 @@
}],
"space-in-parens": [2, "never"],
"space-infix-ops": [2],
"space-return-throw-case": [2],
"space-unary-ops": [2, { "words": true, "nonwords": false }],
"spaced-line-comment": [0, "always"],
"strict": [1],
"strict": [0],
"use-isnan": [2],
"valid-jsdoc": [0],
"valid-typeof": [2],
Expand All @@ -173,4 +168,4 @@
"wrap-regex": [2],
"yoda": [2, "never", { "exceptRange": true }]
}
}
}
10 changes: 1 addition & 9 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ module.exports = function(grunt) {
nodeunit : {
all : ["test/*.js"]
},
sed : {
"version" : {
pattern : "{{VERSION}}",
replacement : "<%= pkg.version %>",
path : ["<%= concat.dist.dest %>"]
}
},
uglify: {
options: {
banner : "/*\n" +
Expand Down Expand Up @@ -73,7 +66,6 @@ module.exports = function(grunt) {
});

// tasks
grunt.loadNpmTasks("grunt-sed");
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-nodeunit");
grunt.loadNpmTasks('grunt-contrib-watch');
Expand All @@ -83,6 +75,6 @@ module.exports = function(grunt) {

// aliases
grunt.registerTask("test", ["eslint", "nodeunit"]);
grunt.registerTask("build", ["concat", "sed", "babel"]);
grunt.registerTask("build", ["concat", "babel"]);
grunt.registerTask("default", ["build", "test", "uglify"]);
};
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015, Jason Mulligan
Copyright (c) 2017, Jason Mulligan
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# filesize.js

[![build status](https://secure.travis-ci.org/avoidwork/filesize.js.png)](http://travis-ci.org/avoidwork/filesize.js) [![Join the chat at https://gitter.im/avoidwork/filesize.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/avoidwork/filesize.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![downloads](https://img.shields.io/npm/dt/filesize.svg)](https://www.npmjs.com/package/filesize)
[![build status](https://secure.travis-ci.org/avoidwork/filesize.js.png)](http://travis-ci.org/avoidwork/filesize.js) [![downloads](https://img.shields.io/npm/dt/filesize.svg)](https://www.npmjs.com/package/filesize)

filesize.js provides a simple way to get a human readable file size string from a number (float or integer) or string.

Expand Down Expand Up @@ -55,9 +55,20 @@ filesize(1024, {output: "exponent"}); // 1
filesize(265318, {standard: "iec"}); // "259.1 KiB"
```

## Partial Application
`filesize.partial()` takes the second parameter of `filesize()` and returns a new function with the configuration applied
upon execution. This can be used to reduce `Object` creation if you call `filesize()` without caching the `descriptor`
in lexical scope.

```javascript
const size = filesize.partial({standard: "iec"});

size(265318); // "259.1 KiB"
```

## How can I load filesize.js?
filesize.js supports AMD loaders (require.js, curl.js, etc.), node.js & npm (```npm install filesize```), or using a script tag.

## License
Copyright (c) 2016 Jason Mulligan
Copyright (c) 2017 Jason Mulligan
Licensed under the BSD-3 license.

0 comments on commit 1ba7b0c

Please sign in to comment.