pure-formatters 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,123 +1,121 @@
1
- # Pure Formatters
2
-
3
- [![Build Status](https://travis-ci.org/travishorn/pure-formatters.svg?branch=master)](https://travis-ci.org/travishorn/pure-formatters)
4
-
5
- > A collection of pure JS functions that return formatted data. Useful in any view engine.
6
-
7
- ## Installation
8
-
9
- ### Node.js
10
-
11
- > npm install --save pure-formatters
12
-
13
- ### Browser
14
-
15
- <script src="node_modules/pure-formatters/dist/pure-formatters.js"></script>
16
-
17
- <!-- Or CDN -->
18
- <script src="https://unpkg.com/pure-formatters/dist/pure-formatters.js"></script>
19
-
20
- ## Usage
21
-
22
- ### Browser
23
-
24
- // After adding script tag, the global variable pf is available
25
- console.log(pf.upperCase('hello world'));
26
-
27
- ### Node.js
28
-
29
- const pf = require('pure-formatters');
30
-
31
- console.log(pf.upperCase('hello world'));
32
-
33
- ### React
34
-
35
- import { Component } from 'react';
36
- import { upperCase } from 'pure-formatters';
37
-
38
- class App extends Component {
39
- render() {
40
- return (
41
- <div>
42
- {upperCase('hello world')}
43
- </div>
44
- );
45
- }
46
- }
47
-
48
- export default App;
49
-
50
- ### Vue
51
-
52
- <template>
53
- <div>
54
- {{ msg | upperCase }}
55
- </div>
56
- </template>
57
-
58
- <script>
59
- import { upperCase } from 'pure-formatters';
60
-
61
- export default {
62
- name: 'component-name',
63
- data() {
64
- return { msg: 'hello world' },
65
- },
66
- filters: {
67
- upperCase,
68
- },
69
- };
70
- </script>
71
-
72
- ## Formatters
73
-
74
- | Symbol | Description | Input | Output |
75
- |--------------|--------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------|--------------------------------------------------------|
76
- | camelCase | Converts string to camel case. | 'Foo Bar' | 'fooBar' |
77
- | | | '--foo-bar--' | 'fooBar' |
78
- | | | '\_\_FOO_BAR\_\_' | 'fooBar' |
79
- | capitalize | Converts the first character of string to upper case and the remaining to lower case | 'FRED' | 'Fred' |
80
- | deburr | Deburrs string by converting Latin-1 Supplement and Latin Extended-A letters to basic Latin letters and removing combining diacritical marks. | 'déjà vu' | 'deja vu' |
81
- | displayNull | If input is null or '', return 'null' | '' | 'null' |
82
- | | | 'Hello World' | 'Hello World' |
83
- | | | '', 'empty' | 'empty' |
84
- | escape | Converts the characters "&", "<", ">", '"', and "'" in string to their corresponding HTML entities. | 'fred, barney, & pebbles' | 'fred, barney, &amp; pebbles' |
85
- | escapeRegExp | Escapes the RegExp special characters "^", "$", "", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "\|" in string. | '\[lodash\]\(htt&#8203;tps://lodash.com/\)' | '\\[lodash\\]\\(htt&#8203;tps://lodash\\.com/\\)' |
86
- | kebabCase | Converts string to kebab case. | 'Foo Bar' | 'foo-bar' |
87
- | | | 'fooBar' | 'foo-bar' |
88
- | | | '\_\_FOO_BAR\_\_' | 'foo-bar' |
89
- | lowerCase | Converts string, as space separated words, to lower case. | '--Foo-Bar--' | 'foo bar' |
90
- | | | 'fooBar' | 'foo bar' |
91
- | | | '\_\_FOO_BAR\_\_' | 'foo bar' |
92
- | lowerFirst | Converts the first character of string to lower case. | 'Fred' | 'fred' |
93
- | | | 'FRED' | 'fRED' |
94
- | pad | Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length. | 'abc', 8 | ' abc ' |
95
- | | | 'abc', 8, '_-' | '_-abc_-_' |
96
- | | | 'abc', 3 | 'abc' |
97
- | sentenceList | Combines array elements with commas and "and" | ['Bettye Norton'] | 'Bettye Norton' |
98
- | | | ['Bettye Norton', 'Melisa Reed'] | 'Bettye Norton and Melisa Reed' |
99
- | | | ['Bettye Norton', 'Melisa Reed', 'Kari Osborne'] | 'Bettye Norton, Melisa Reed, and Kari Osborne' |
100
- | | | [{ name: 'Bettye Norton' }], 'name' | 'Bettye Norton' |
101
- | upperCase | Converts string, as space separated words, to upper case. | '--foo-bar' | 'FOO BAR' |
102
- | | | 'fooBar' | 'FOO BAR' |
103
- | | | '\_\_foo_bar\_\_' | 'FOO BAR' |
104
- | usd | Adds a dollar sign and rounds to 2 decimal places | 1.5 | '$1.50' |
105
- | | | 150, 'c' | '$1.50' |
106
- | padEnd | Description, input, and output coming soon. | | |
107
- | padStart | Description, input, and output coming soon. | | |
108
- | repeat | Description, input, and output coming soon. | | |
109
- | replace | Description, input, and output coming soon. | | |
110
- | snakeCase | Description, input, and output coming soon. | | |
111
- | startCase | Description, input, and output coming soon. | | |
112
- | toLower | Description, input, and output coming soon. | | |
113
- | toUpper | Description, input, and output coming soon. | | |
114
- | trim | Description, input, and output coming soon. | | |
115
- | trimEnd | Description, input, and output coming soon. | | |
116
- | trimStart | Description, input, and output coming soon. | | |
117
- | truncate | Description, input, and output coming soon. | | |
118
- | unescape | Description, input, and output coming soon. | | |
119
- | upperFirst | Description, input, and output coming soon. | | |
120
-
121
- ## Contributing
122
-
123
- See [CONTRIBUTING.md](https://github.com/travishorn/pure-formatters/blob/master/CONTRIBUTING.md)
1
+ # Pure Formatters
2
+
3
+ A collection of pure JS functions that return formatted data. Useful in any view engine.
4
+
5
+ ## Installation
6
+
7
+ ### Node.js
8
+
9
+ npm install --save pure-formatters
10
+
11
+ ### Browser
12
+
13
+ <script src="node_modules/pure-formatters/dist/pure-formatters.js"></script>
14
+
15
+ <!-- Or CDN -->
16
+ <script src="https://unpkg.com/pure-formatters/dist/pure-formatters.js"></script>
17
+
18
+ ## Usage
19
+
20
+ ### Browser
21
+
22
+ // After adding script tag, the global variable pf is available
23
+ console.log(pf.upperCase('hello world'));
24
+
25
+ ### Node.js
26
+
27
+ const pf = require('pure-formatters');
28
+
29
+ console.log(pf.upperCase('hello world'));
30
+
31
+ ### React
32
+
33
+ import { Component } from 'react';
34
+ import { upperCase } from 'pure-formatters';
35
+
36
+ class App extends Component {
37
+ render() {
38
+ return (
39
+ <div>
40
+ {upperCase('hello world')}
41
+ </div>
42
+ );
43
+ }
44
+ }
45
+
46
+ export default App;
47
+
48
+ ### Vue
49
+
50
+ <template>
51
+ <div>
52
+ {{ msg | upperCase }}
53
+ </div>
54
+ </template>
55
+
56
+ <script>
57
+ import { upperCase } from 'pure-formatters';
58
+
59
+ export default {
60
+ name: 'component-name',
61
+ data() {
62
+ return { msg: 'hello world' },
63
+ },
64
+ filters: {
65
+ upperCase,
66
+ },
67
+ };
68
+ </script>
69
+
70
+ ## Formatters
71
+
72
+ | Symbol | Description | Input | Output |
73
+ | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------ | ------------------------------------------------- |
74
+ | camelCase | Converts string to camel case. | 'Foo Bar' | 'fooBar' |
75
+ | | | '--foo-bar--' | 'fooBar' |
76
+ | | | '\_\_FOO_BAR\_\_' | 'fooBar' |
77
+ | capitalize | Converts the first character of string to upper case and the remaining to lower case | 'FRED' | 'Fred' |
78
+ | deburr | Deburrs string by converting Latin-1 Supplement and Latin Extended-A letters to basic Latin letters and removing combining diacritical marks. | 'déjà vu' | 'deja vu' |
79
+ | displayNull | If input is null or '', return 'null' | '' | 'null' |
80
+ | | | 'Hello World' | 'Hello World' |
81
+ | | | '', 'empty' | 'empty' |
82
+ | escape | Converts the characters "&", "<", ">", '"', and "'" in string to their corresponding HTML entities. | 'fred, barney, & pebbles' | 'fred, barney, &amp; pebbles' |
83
+ | escapeRegExp | Escapes the RegExp special characters "^", "$", "", ".", "\*", "+", "?", "(", ")", "[", "]", "{", "}", and "\|" in string. | '\[lodash\]\(htt&#8203;tps://lodash.com/\)' | '\\[lodash\\]\\(htt&#8203;tps://lodash\\.com/\\)' |
84
+ | kebabCase | Converts string to kebab case. | 'Foo Bar' | 'foo-bar' |
85
+ | | | 'fooBar' | 'foo-bar' |
86
+ | | | '\_\_FOO_BAR\_\_' | 'foo-bar' |
87
+ | lowerCase | Converts string, as space separated words, to lower case. | '--Foo-Bar--' | 'foo bar' |
88
+ | | | 'fooBar' | 'foo bar' |
89
+ | | | '\_\_FOO_BAR\_\_' | 'foo bar' |
90
+ | lowerFirst | Converts the first character of string to lower case. | 'Fred' | 'fred' |
91
+ | | | 'FRED' | 'fRED' |
92
+ | pad | Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length. | 'abc', 8 | ' abc ' |
93
+ | | | 'abc', 8, '\_-' | '_-abc_-\_' |
94
+ | | | 'abc', 3 | 'abc' |
95
+ | sentenceList | Combines array elements with commas and "and" | ['Bettye Norton'] | 'Bettye Norton' |
96
+ | | | ['Bettye Norton', 'Melisa Reed'] | 'Bettye Norton and Melisa Reed' |
97
+ | | | ['Bettye Norton', 'Melisa Reed', 'Kari Osborne'] | 'Bettye Norton, Melisa Reed, and Kari Osborne' |
98
+ | | | [{ name: 'Bettye Norton' }], 'name' | 'Bettye Norton' |
99
+ | upperCase | Converts string, as space separated words, to upper case. | '--foo-bar' | 'FOO BAR' |
100
+ | | | 'fooBar' | 'FOO BAR' |
101
+ | | | '\_\_foo_bar\_\_' | 'FOO BAR' |
102
+ | usd | Adds a dollar sign and rounds to 2 decimal places | 1.5 | '$1.50' |
103
+ | | | 150, 'c' | '$1.50' |
104
+ | padEnd | Description, input, and output coming soon. | | |
105
+ | padStart | Description, input, and output coming soon. | | |
106
+ | repeat | Description, input, and output coming soon. | | |
107
+ | replace | Description, input, and output coming soon. | | |
108
+ | snakeCase | Description, input, and output coming soon. | | |
109
+ | startCase | Description, input, and output coming soon. | | |
110
+ | toLower | Description, input, and output coming soon. | | |
111
+ | toUpper | Description, input, and output coming soon. | | |
112
+ | trim | Description, input, and output coming soon. | | |
113
+ | trimEnd | Description, input, and output coming soon. | | |
114
+ | trimStart | Description, input, and output coming soon. | | |
115
+ | truncate | Description, input, and output coming soon. | | |
116
+ | unescape | Description, input, and output coming soon. | | |
117
+ | upperFirst | Description, input, and output coming soon. | | |
118
+
119
+ ## Contributing
120
+
121
+ See [CONTRIBUTING.md](https://github.com/travishorn/pure-formatters/blob/master/CONTRIBUTING.md)
@@ -77,9 +77,9 @@ module.exports = require("lodash");
77
77
  "use strict";
78
78
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
79
79
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
80
-
81
-
82
- /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["camelCase"])(str));
80
+
81
+
82
+ /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["camelCase"])(str));
83
83
 
84
84
 
85
85
  /***/ }),
@@ -89,9 +89,9 @@ module.exports = require("lodash");
89
89
  "use strict";
90
90
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
91
91
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
92
-
93
-
94
- /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["capitalize"])(str));
92
+
93
+
94
+ /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["capitalize"])(str));
95
95
 
96
96
 
97
97
  /***/ }),
@@ -101,9 +101,9 @@ module.exports = require("lodash");
101
101
  "use strict";
102
102
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
103
103
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
104
-
105
-
106
- /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["deburr"])(str));
104
+
105
+
106
+ /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["deburr"])(str));
107
107
 
108
108
 
109
109
  /***/ }),
@@ -111,11 +111,11 @@ module.exports = require("lodash");
111
111
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
112
112
 
113
113
  "use strict";
114
- /* harmony default export */ __webpack_exports__["a"] = ((input, display) => {
115
- if (input === null) return display || 'null';
116
- if (input === '') return display || 'null';
117
- return input;
118
- });
114
+ /* harmony default export */ __webpack_exports__["a"] = ((input, display) => {
115
+ if (input === null) return display || 'null';
116
+ if (input === '') return display || 'null';
117
+ return input;
118
+ });
119
119
 
120
120
 
121
121
  /***/ }),
@@ -125,9 +125,9 @@ module.exports = require("lodash");
125
125
  "use strict";
126
126
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
127
127
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
128
-
129
-
130
- /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["escape"])(str));
128
+
129
+
130
+ /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["escape"])(str));
131
131
 
132
132
 
133
133
  /***/ }),
@@ -137,9 +137,9 @@ module.exports = require("lodash");
137
137
  "use strict";
138
138
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
139
139
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
140
-
141
-
142
- /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["escapeRegExp"])(str));
140
+
141
+
142
+ /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["escapeRegExp"])(str));
143
143
 
144
144
 
145
145
  /***/ }),
@@ -149,9 +149,9 @@ module.exports = require("lodash");
149
149
  "use strict";
150
150
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
151
151
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
152
-
153
-
154
- /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["kebabCase"])(str));
152
+
153
+
154
+ /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["kebabCase"])(str));
155
155
 
156
156
 
157
157
  /***/ }),
@@ -161,9 +161,9 @@ module.exports = require("lodash");
161
161
  "use strict";
162
162
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
163
163
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
164
-
165
-
166
- /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["lowerCase"])(str));
164
+
165
+
166
+ /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["lowerCase"])(str));
167
167
 
168
168
 
169
169
  /***/ }),
@@ -173,9 +173,9 @@ module.exports = require("lodash");
173
173
  "use strict";
174
174
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
175
175
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
176
-
177
-
178
- /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["lowerFirst"])(str));
176
+
177
+
178
+ /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["lowerFirst"])(str));
179
179
 
180
180
 
181
181
  /***/ }),
@@ -185,9 +185,9 @@ module.exports = require("lodash");
185
185
  "use strict";
186
186
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
187
187
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
188
-
189
-
190
- /* harmony default export */ __webpack_exports__["a"] = ((str, len, chars) => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["pad"])(str, len, chars));
188
+
189
+
190
+ /* harmony default export */ __webpack_exports__["a"] = ((str, len, chars) => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["pad"])(str, len, chars));
191
191
 
192
192
 
193
193
  /***/ }),
@@ -197,9 +197,9 @@ module.exports = require("lodash");
197
197
  "use strict";
198
198
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
199
199
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
200
-
201
-
202
- /* harmony default export */ __webpack_exports__["a"] = ((str, len, chars) => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["padEnd"])(str, len, chars));
200
+
201
+
202
+ /* harmony default export */ __webpack_exports__["a"] = ((str, len, chars) => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["padEnd"])(str, len, chars));
203
203
 
204
204
 
205
205
  /***/ }),
@@ -209,9 +209,9 @@ module.exports = require("lodash");
209
209
  "use strict";
210
210
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
211
211
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
212
-
213
-
214
- /* harmony default export */ __webpack_exports__["a"] = ((str, len, chars) => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["padStart"])(str, len, chars));
212
+
213
+
214
+ /* harmony default export */ __webpack_exports__["a"] = ((str, len, chars) => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["padStart"])(str, len, chars));
215
215
 
216
216
 
217
217
  /***/ }),
@@ -221,9 +221,9 @@ module.exports = require("lodash");
221
221
  "use strict";
222
222
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
223
223
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
224
-
225
-
226
- /* harmony default export */ __webpack_exports__["a"] = ((str, n) => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["repeat"])(str, n));
224
+
225
+
226
+ /* harmony default export */ __webpack_exports__["a"] = ((str, n) => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["repeat"])(str, n));
227
227
 
228
228
 
229
229
  /***/ }),
@@ -233,9 +233,9 @@ module.exports = require("lodash");
233
233
  "use strict";
234
234
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
235
235
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
236
-
237
-
238
- /* harmony default export */ __webpack_exports__["a"] = ((str, pattern, replacement) => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["replace"])(str, pattern, replacement));
236
+
237
+
238
+ /* harmony default export */ __webpack_exports__["a"] = ((str, pattern, replacement) => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["replace"])(str, pattern, replacement));
239
239
 
240
240
 
241
241
  /***/ }),
@@ -243,41 +243,41 @@ module.exports = require("lodash");
243
243
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
244
244
 
245
245
  "use strict";
246
- /* harmony default export */ __webpack_exports__["a"] = ((inputArray, key) => {
247
- let output = '';
248
-
249
- if (inputArray.length === 1) {
250
- if (!key) {
251
- output = inputArray[0];
252
- } else {
253
- output = inputArray[0][key];
254
- }
255
- } else if (inputArray.length === 2) {
256
- if (!key) {
257
- output = `${inputArray[0]} and ${inputArray[1]}`;
258
- } else {
259
- output = `${inputArray[0][key]} and ${inputArray[1][key]}`;
260
- }
261
- } else {
262
- inputArray.forEach((item, i) => {
263
- if (i === inputArray.length - 1) {
264
- output += 'and ';
265
- }
266
-
267
- if (!key) {
268
- output += item;
269
- } else {
270
- output += item[key];
271
- }
272
-
273
- if (inputArray.length !== 2 && i < inputArray.length - 1) {
274
- output += ', ';
275
- }
276
- });
277
- }
278
-
279
- return output;
280
- });
246
+ /* harmony default export */ __webpack_exports__["a"] = ((inputArray, key) => {
247
+ let output = '';
248
+
249
+ if (inputArray.length === 1) {
250
+ if (!key) {
251
+ output = inputArray[0];
252
+ } else {
253
+ output = inputArray[0][key];
254
+ }
255
+ } else if (inputArray.length === 2) {
256
+ if (!key) {
257
+ output = `${inputArray[0]} and ${inputArray[1]}`;
258
+ } else {
259
+ output = `${inputArray[0][key]} and ${inputArray[1][key]}`;
260
+ }
261
+ } else {
262
+ inputArray.forEach((item, i) => {
263
+ if (i === inputArray.length - 1) {
264
+ output += 'and ';
265
+ }
266
+
267
+ if (!key) {
268
+ output += item;
269
+ } else {
270
+ output += item[key];
271
+ }
272
+
273
+ if (inputArray.length !== 2 && i < inputArray.length - 1) {
274
+ output += ', ';
275
+ }
276
+ });
277
+ }
278
+
279
+ return output;
280
+ });
281
281
 
282
282
 
283
283
  /***/ }),
@@ -287,9 +287,9 @@ module.exports = require("lodash");
287
287
  "use strict";
288
288
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
289
289
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
290
-
291
-
292
- /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["snakeCase"])(str));
290
+
291
+
292
+ /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["snakeCase"])(str));
293
293
 
294
294
 
295
295
  /***/ }),
@@ -299,9 +299,9 @@ module.exports = require("lodash");
299
299
  "use strict";
300
300
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
301
301
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
302
-
303
-
304
- /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["startCase"])(str));
302
+
303
+
304
+ /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["startCase"])(str));
305
305
 
306
306
 
307
307
  /***/ }),
@@ -311,9 +311,9 @@ module.exports = require("lodash");
311
311
  "use strict";
312
312
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
313
313
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
314
-
315
-
316
- /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["toLower"])(str));
314
+
315
+
316
+ /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["toLower"])(str));
317
317
 
318
318
 
319
319
  /***/ }),
@@ -323,9 +323,9 @@ module.exports = require("lodash");
323
323
  "use strict";
324
324
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
325
325
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
326
-
327
-
328
- /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["toUpper"])(str));
326
+
327
+
328
+ /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["toUpper"])(str));
329
329
 
330
330
 
331
331
  /***/ }),
@@ -335,9 +335,9 @@ module.exports = require("lodash");
335
335
  "use strict";
336
336
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
337
337
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
338
-
339
-
340
- /* harmony default export */ __webpack_exports__["a"] = ((str, chars) => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["trim"])(str, chars));
338
+
339
+
340
+ /* harmony default export */ __webpack_exports__["a"] = ((str, chars) => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["trim"])(str, chars));
341
341
 
342
342
 
343
343
  /***/ }),
@@ -347,9 +347,9 @@ module.exports = require("lodash");
347
347
  "use strict";
348
348
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
349
349
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
350
-
351
-
352
- /* harmony default export */ __webpack_exports__["a"] = ((str, chars) => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["trimEnd"])(str, chars));
350
+
351
+
352
+ /* harmony default export */ __webpack_exports__["a"] = ((str, chars) => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["trimEnd"])(str, chars));
353
353
 
354
354
 
355
355
  /***/ }),
@@ -359,9 +359,9 @@ module.exports = require("lodash");
359
359
  "use strict";
360
360
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
361
361
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
362
-
363
-
364
- /* harmony default export */ __webpack_exports__["a"] = ((str, chars) => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["trimStart"])(str, chars));
362
+
363
+
364
+ /* harmony default export */ __webpack_exports__["a"] = ((str, chars) => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["trimStart"])(str, chars));
365
365
 
366
366
 
367
367
  /***/ }),
@@ -371,9 +371,9 @@ module.exports = require("lodash");
371
371
  "use strict";
372
372
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
373
373
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
374
-
375
-
376
- /* harmony default export */ __webpack_exports__["a"] = ((str, options) => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["truncate"])(str, options));
374
+
375
+
376
+ /* harmony default export */ __webpack_exports__["a"] = ((str, options) => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["truncate"])(str, options));
377
377
 
378
378
 
379
379
  /***/ }),
@@ -383,9 +383,9 @@ module.exports = require("lodash");
383
383
  "use strict";
384
384
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
385
385
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
386
-
387
-
388
- /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["unescape"])(str));
386
+
387
+
388
+ /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["unescape"])(str));
389
389
 
390
390
 
391
391
  /***/ }),
@@ -395,9 +395,9 @@ module.exports = require("lodash");
395
395
  "use strict";
396
396
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
397
397
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
398
-
399
-
400
- /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["upperCase"])(str));
398
+
399
+
400
+ /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["upperCase"])(str));
401
401
 
402
402
 
403
403
  /***/ }),
@@ -407,9 +407,9 @@ module.exports = require("lodash");
407
407
  "use strict";
408
408
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash__ = __webpack_require__(0);
409
409
  /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_lodash__);
410
-
411
-
412
- /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["upperFirst"])(str));
410
+
411
+
412
+ /* harmony default export */ __webpack_exports__["a"] = (str => Object(__WEBPACK_IMPORTED_MODULE_0_lodash__["upperFirst"])(str));
413
413
 
414
414
 
415
415
  /***/ }),
@@ -417,15 +417,15 @@ module.exports = require("lodash");
417
417
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
418
418
 
419
419
  "use strict";
420
- /* harmony default export */ __webpack_exports__["a"] = ((amount, denomination) => {
421
- let nAmount = parseFloat(amount);
422
-
423
- if (denomination === 'c') {
424
- nAmount /= 100;
425
- }
426
-
427
- return `$${nAmount.toFixed(2)}`;
428
- });
420
+ /* harmony default export */ __webpack_exports__["a"] = ((amount, denomination) => {
421
+ let nAmount = parseFloat(amount);
422
+
423
+ if (denomination === 'c') {
424
+ nAmount /= 100;
425
+ }
426
+
427
+ return `$${nAmount.toFixed(2)}`;
428
+ });
429
429
 
430
430
 
431
431
  /***/ }),
@@ -488,91 +488,91 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
488
488
  /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "upperCase", function() { return __WEBPACK_IMPORTED_MODULE_24__upperCase__["a"]; });
489
489
  /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "upperFirst", function() { return __WEBPACK_IMPORTED_MODULE_25__upperFirst__["a"]; });
490
490
  /* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "usd", function() { return __WEBPACK_IMPORTED_MODULE_26__usd__["a"]; });
491
-
492
-
493
-
494
-
495
-
496
-
497
-
498
-
499
-
500
-
501
-
502
-
503
-
504
-
505
-
506
-
507
-
508
-
509
-
510
-
511
-
512
-
513
-
514
-
515
-
516
-
517
-
518
-
519
-
520
-
521
-
522
-
523
-
524
-
525
-
526
-
527
-
528
-
529
-
530
-
531
-
532
-
533
-
534
-
535
-
536
-
537
-
538
-
539
-
540
-
541
-
542
-
543
-
544
-
545
-
546
-
547
- /* harmony default export */ __webpack_exports__["default"] = ({
548
- camelCase: __WEBPACK_IMPORTED_MODULE_0__camelCase__["a" /* default */],
549
- capitalize: __WEBPACK_IMPORTED_MODULE_1__capitalize__["a" /* default */],
550
- deburr: __WEBPACK_IMPORTED_MODULE_2__deburr__["a" /* default */],
551
- displayNull: __WEBPACK_IMPORTED_MODULE_3__displayNull__["a" /* default */],
552
- escape: __WEBPACK_IMPORTED_MODULE_4__escape__["a" /* default */],
553
- escapeRegExp: __WEBPACK_IMPORTED_MODULE_5__escapeRegExp__["a" /* default */],
554
- kebabCase: __WEBPACK_IMPORTED_MODULE_6__kebabCase__["a" /* default */],
555
- lowerCase: __WEBPACK_IMPORTED_MODULE_7__lowerCase__["a" /* default */],
556
- lowerFirst: __WEBPACK_IMPORTED_MODULE_8__lowerFirst__["a" /* default */],
557
- pad: __WEBPACK_IMPORTED_MODULE_9__pad__["a" /* default */],
558
- padEnd: __WEBPACK_IMPORTED_MODULE_10__padEnd__["a" /* default */],
559
- padStart: __WEBPACK_IMPORTED_MODULE_11__padStart__["a" /* default */],
560
- repeat: __WEBPACK_IMPORTED_MODULE_12__repeat__["a" /* default */],
561
- replace: __WEBPACK_IMPORTED_MODULE_13__replace__["a" /* default */],
562
- sentenceList: __WEBPACK_IMPORTED_MODULE_14__sentenceList__["a" /* default */],
563
- snakeCase: __WEBPACK_IMPORTED_MODULE_15__snakeCase__["a" /* default */],
564
- startCase: __WEBPACK_IMPORTED_MODULE_16__startCase__["a" /* default */],
565
- toLower: __WEBPACK_IMPORTED_MODULE_17__toLower__["a" /* default */],
566
- toUpper: __WEBPACK_IMPORTED_MODULE_18__toUpper__["a" /* default */],
567
- trim: __WEBPACK_IMPORTED_MODULE_19__trim__["a" /* default */],
568
- trimEnd: __WEBPACK_IMPORTED_MODULE_20__trimEnd__["a" /* default */],
569
- trimStart: __WEBPACK_IMPORTED_MODULE_21__trimStart__["a" /* default */],
570
- truncate: __WEBPACK_IMPORTED_MODULE_22__truncate__["a" /* default */],
571
- unescape: __WEBPACK_IMPORTED_MODULE_23__unescape__["a" /* default */],
572
- upperCase: __WEBPACK_IMPORTED_MODULE_24__upperCase__["a" /* default */],
573
- upperFirst: __WEBPACK_IMPORTED_MODULE_25__upperFirst__["a" /* default */],
574
- usd: __WEBPACK_IMPORTED_MODULE_26__usd__["a" /* default */],
575
- });
491
+
492
+
493
+
494
+
495
+
496
+
497
+
498
+
499
+
500
+
501
+
502
+
503
+
504
+
505
+
506
+
507
+
508
+
509
+
510
+
511
+
512
+
513
+
514
+
515
+
516
+
517
+
518
+
519
+
520
+
521
+
522
+
523
+
524
+
525
+
526
+
527
+
528
+
529
+
530
+
531
+
532
+
533
+
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+
542
+
543
+
544
+
545
+
546
+
547
+ /* harmony default export */ __webpack_exports__["default"] = ({
548
+ camelCase: __WEBPACK_IMPORTED_MODULE_0__camelCase__["a" /* default */],
549
+ capitalize: __WEBPACK_IMPORTED_MODULE_1__capitalize__["a" /* default */],
550
+ deburr: __WEBPACK_IMPORTED_MODULE_2__deburr__["a" /* default */],
551
+ displayNull: __WEBPACK_IMPORTED_MODULE_3__displayNull__["a" /* default */],
552
+ escape: __WEBPACK_IMPORTED_MODULE_4__escape__["a" /* default */],
553
+ escapeRegExp: __WEBPACK_IMPORTED_MODULE_5__escapeRegExp__["a" /* default */],
554
+ kebabCase: __WEBPACK_IMPORTED_MODULE_6__kebabCase__["a" /* default */],
555
+ lowerCase: __WEBPACK_IMPORTED_MODULE_7__lowerCase__["a" /* default */],
556
+ lowerFirst: __WEBPACK_IMPORTED_MODULE_8__lowerFirst__["a" /* default */],
557
+ pad: __WEBPACK_IMPORTED_MODULE_9__pad__["a" /* default */],
558
+ padEnd: __WEBPACK_IMPORTED_MODULE_10__padEnd__["a" /* default */],
559
+ padStart: __WEBPACK_IMPORTED_MODULE_11__padStart__["a" /* default */],
560
+ repeat: __WEBPACK_IMPORTED_MODULE_12__repeat__["a" /* default */],
561
+ replace: __WEBPACK_IMPORTED_MODULE_13__replace__["a" /* default */],
562
+ sentenceList: __WEBPACK_IMPORTED_MODULE_14__sentenceList__["a" /* default */],
563
+ snakeCase: __WEBPACK_IMPORTED_MODULE_15__snakeCase__["a" /* default */],
564
+ startCase: __WEBPACK_IMPORTED_MODULE_16__startCase__["a" /* default */],
565
+ toLower: __WEBPACK_IMPORTED_MODULE_17__toLower__["a" /* default */],
566
+ toUpper: __WEBPACK_IMPORTED_MODULE_18__toUpper__["a" /* default */],
567
+ trim: __WEBPACK_IMPORTED_MODULE_19__trim__["a" /* default */],
568
+ trimEnd: __WEBPACK_IMPORTED_MODULE_20__trimEnd__["a" /* default */],
569
+ trimStart: __WEBPACK_IMPORTED_MODULE_21__trimStart__["a" /* default */],
570
+ truncate: __WEBPACK_IMPORTED_MODULE_22__truncate__["a" /* default */],
571
+ unescape: __WEBPACK_IMPORTED_MODULE_23__unescape__["a" /* default */],
572
+ upperCase: __WEBPACK_IMPORTED_MODULE_24__upperCase__["a" /* default */],
573
+ upperFirst: __WEBPACK_IMPORTED_MODULE_25__upperFirst__["a" /* default */],
574
+ usd: __WEBPACK_IMPORTED_MODULE_26__usd__["a" /* default */],
575
+ });
576
576
 
577
577
 
578
578
  /***/ })
package/index.js CHANGED
@@ -1 +1 @@
1
- module.exports = require('./dist/pure-formatters.cjs');
1
+ module.exports = require('./dist/pure-formatters.cjs');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pure-formatters",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "A collection of pure JS functions that return formatted data. Useful in any view engine.",
5
5
  "main": "index.js",
6
6
  "scripts": {