Skip to content

Commit 1ba7b0c

Browse files
committed
Creating filesize.partial() for creating a partial application / functional programming style, updating dependencies, fixing lint errors, updating README & LICENSE copyright year, updating README to cover filesize.partial()
1 parent 048976d commit 1ba7b0c

12 files changed

+268
-256
lines changed

.eslintrc

+12-17
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
{
2-
"parser": "babel-eslint",
3-
"rules": {
4-
"strict": 0
5-
},
62
"env": {
73
"browser": true,
84
"node": true,
95
"es6": true,
106
"amd": true
117
},
128
"ecmaFeatures": {
13-
"jsx": true,
9+
"jsx": false,
1410
"superInFunctions": false,
1511
"classes": false,
1612
"modules": [2]
1713
},
1814
"rules": {
15+
"arrow-parens": [2, "as-needed"],
16+
"arrow-spacing": [2, {"before": true, "after": true}],
1917
"block-scoped-var": [0],
2018
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
2119
"camelcase": [0],
@@ -33,9 +31,9 @@
3331
"func-names": [0],
3432
"func-style": [0, "declaration"],
3533
"generator-star-spacing": [2, "after"],
36-
"strict": [2, "always"],
3734
"guard-for-in": [0],
3835
"handle-callback-err": [0],
36+
"indent": ["error", "tab", {"VariableDeclarator": {"var": 1, "let": 1, "const": 1}, "SwitchCase": 1}],
3937
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
4038
"quotes": [2, "double", "avoid-escape"],
4139
"max-depth": [0, 4],
@@ -46,6 +44,7 @@
4644
"new-parens": [2],
4745
"new-cap": [2, { "capIsNewExceptions": ["ToInteger", "ToObject", "ToPrimitive", "ToUint32"] }],
4846
"newline-after-var": [0],
47+
"newline-before-return": [2],
4948
"no-alert": [2],
5049
"no-array-constructor": [2],
5150
"no-bitwise": [0],
@@ -64,14 +63,12 @@
6463
"no-duplicate-case": [2],
6564
"no-else-return": [0],
6665
"no-empty": [2],
67-
"no-empty-label": [2],
6866
"no-eq-null": [0],
6967
"no-eval": [2],
7068
"no-ex-assign": [2],
7169
"no-extend-native": [1],
7270
"no-extra-bind": [2],
7371
"no-extra-boolean-cast": [2],
74-
"no-extra-parens": [0],
7572
"no-extra-semi": [1],
7673
"no-empty-character-class": [2],
7774
"no-fallthrough": [2],
@@ -97,7 +94,7 @@
9794
"no-negated-in-lhs": [2],
9895
"no-nested-ternary": [0],
9996
"no-new": [2],
100-
"no-new-func": [2],
97+
"no-new-func": [0],
10198
"no-new-object": [2],
10299
"no-new-require": [0],
103100
"no-new-wrappers": [2],
@@ -113,14 +110,13 @@
113110
"no-redeclare": [2],
114111
"no-regex-spaces": [2],
115112
"no-reserved-keys": [0],
116-
"no-restricted-modules": [0],
113+
"no-reno-new-funced-modules": [0],
117114
"no-return-assign": [2],
118115
"no-script-url": [2],
119116
"no-self-compare": [0],
120117
"no-sequences": [2],
121118
"no-shadow": [2],
122119
"no-shadow-restricted-names": [2],
123-
"semi-spacing": [2],
124120
"no-spaced-func": [2],
125121
"no-sparse-arrays": [2],
126122
"no-sync": [0],
@@ -133,7 +129,7 @@
133129
"no-underscore-dangle": [0],
134130
"no-unreachable": [2],
135131
"no-unused-expressions": [2],
136-
"no-unused-vars": [1, { "vars": "all", "args": "after-used" }],
132+
"no-unused-vars": [2, { "vars": "all", "args": "after-used" }],
137133
"no-use-before-define": [2],
138134
"no-void": [0],
139135
"no-warning-comments": [0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }],
@@ -148,9 +144,9 @@
148144
"semi": [2],
149145
"semi-spacing": [2, { "before": false, "after": true }],
150146
"sort-vars": [0],
151-
"space-after-keywords": [2, "always"],
147+
"keyword-spacing": [2],
152148
"space-before-function-paren": [2, { "anonymous": "always", "named": "always" }],
153-
"space-before-blocks": [0, "always"],
149+
"space-before-blocks": [2, "always"],
154150
"space-in-brackets": [0, "never", {
155151
"singleValue": true,
156152
"arraysInArrays": false,
@@ -161,10 +157,9 @@
161157
}],
162158
"space-in-parens": [2, "never"],
163159
"space-infix-ops": [2],
164-
"space-return-throw-case": [2],
165160
"space-unary-ops": [2, { "words": true, "nonwords": false }],
166161
"spaced-line-comment": [0, "always"],
167-
"strict": [1],
162+
"strict": [0],
168163
"use-isnan": [2],
169164
"valid-jsdoc": [0],
170165
"valid-typeof": [2],
@@ -173,4 +168,4 @@
173168
"wrap-regex": [2],
174169
"yoda": [2, "never", { "exceptRange": true }]
175170
}
176-
}
171+
}

Gruntfile.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ module.exports = function(grunt) {
3838
nodeunit : {
3939
all : ["test/*.js"]
4040
},
41-
sed : {
42-
"version" : {
43-
pattern : "{{VERSION}}",
44-
replacement : "<%= pkg.version %>",
45-
path : ["<%= concat.dist.dest %>"]
46-
}
47-
},
4841
uglify: {
4942
options: {
5043
banner : "/*\n" +
@@ -73,7 +66,6 @@ module.exports = function(grunt) {
7366
});
7467

7568
// tasks
76-
grunt.loadNpmTasks("grunt-sed");
7769
grunt.loadNpmTasks("grunt-contrib-concat");
7870
grunt.loadNpmTasks("grunt-contrib-nodeunit");
7971
grunt.loadNpmTasks('grunt-contrib-watch');
@@ -83,6 +75,6 @@ module.exports = function(grunt) {
8375

8476
// aliases
8577
grunt.registerTask("test", ["eslint", "nodeunit"]);
86-
grunt.registerTask("build", ["concat", "sed", "babel"]);
78+
grunt.registerTask("build", ["concat", "babel"]);
8779
grunt.registerTask("default", ["build", "test", "uglify"]);
8880
};

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2015, Jason Mulligan
1+
Copyright (c) 2017, Jason Mulligan
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without

README.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# filesize.js
22

3-
[![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)
3+
[![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)
44

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

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

58+
## Partial Application
59+
`filesize.partial()` takes the second parameter of `filesize()` and returns a new function with the configuration applied
60+
upon execution. This can be used to reduce `Object` creation if you call `filesize()` without caching the `descriptor`
61+
in lexical scope.
62+
63+
```javascript
64+
const size = filesize.partial({standard: "iec"});
65+
66+
size(265318); // "259.1 KiB"
67+
```
68+
5869
## How can I load filesize.js?
5970
filesize.js supports AMD loaders (require.js, curl.js, etc.), node.js & npm (```npm install filesize```), or using a script tag.
6071

6172
## License
62-
Copyright (c) 2016 Jason Mulligan
73+
Copyright (c) 2017 Jason Mulligan
6374
Licensed under the BSD-3 license.

0 commit comments

Comments
 (0)