@jaredwray/fumanchu 1.0.2 → 1.0.3

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
@@ -13,7 +13,6 @@ Handlebars + Helpers Together
13
13
 
14
14
  ## Table of Contents
15
15
  * [Using in Nodejs](#using-in-nodejs)
16
- * [Using in Browser](#using-in-browser)
17
16
  * [Helpers](#helpers)
18
17
  * [How to Contribute](#how-to-contribute)
19
18
  * [License and Copyright](#license-and-copyright)
@@ -21,7 +20,9 @@ Handlebars + Helpers Together
21
20
  ## Usage Nodejs
22
21
 
23
22
  ```bash
24
- npm install @jaredwray/fumanchu
23
+ npm install @jaredwray/fumanchu --save
24
+ // or
25
+ yarn add @jaredwray/fumanchu
25
26
  ```
26
27
 
27
28
  ```javascript
@@ -78,13 +79,13 @@ Visit the: [code](lib/array.js) | [unit tests](test/array.js) | [issues](https:/
78
79
  * **[isArray](#isArray)** ([code](lib/array.js#L244) | [tests](test/array.js#L172))
79
80
  * **[itemAt](#itemAt)** ([code](lib/array.js#L263) | [tests](test/array.js#L182))
80
81
  * **[join](#join)** ([code](lib/array.js#L294) | [tests](test/array.js#L225))
81
- * **[equalsLength](#equalsLength)** ([code](lib/array.js#L313) | [no tests])
82
+ * **[equalsLength](#equalsLength)** ([code](lib/array.js#L313) | [tests](test/array.js#L494))
82
83
  * **[last](#last)** ([code](lib/array.js#L349) | [tests](test/array.js#L240))
83
84
  * **[length](#length)** ([code](lib/array.js#L379) | [tests](test/array.js#L254))
84
85
  * **[lengthEqual](#lengthEqual)** ([code](lib/array.js#L395) | [tests](test/array.js#L254))
85
86
  * **[map](#map)** ([code](lib/array.js#L414) | [tests](test/array.js#L266))
86
87
  * **[pluck](#pluck)** ([code](lib/array.js#L445) | [tests](test/array.js#L300))
87
- * **[reverse](#reverse)** ([code](lib/array.js#L473) | [no tests])
88
+ * **[reverse](#reverse)** ([code](lib/array.js#L473) | [tests](test/array.js#L506))
88
89
  * **[some](#some)** ([code](lib/array.js#L504) | [tests](test/array.js#L308))
89
90
  * **[sort](#sort)** ([code](lib/array.js#L532) | [tests](test/array.js#L333))
90
91
  * **[sortBy](#sortBy)** ([code](lib/array.js#L557) | [tests](test/array.js#L358))
@@ -133,7 +134,7 @@ Visit the: [code](lib/comparison.js) | [unit tests](test/comparison.js) | [issue
133
134
  * **[lt](#lt)** ([code](lib/comparison.js#L411) | [tests](test/comparison.js#L449))
134
135
  * **[lte](#lte)** ([code](lib/comparison.js#L435) | [tests](test/comparison.js#L476))
135
136
  * **[neither](#neither)** ([code](lib/comparison.js#L456) | [tests](test/comparison.js#L511))
136
- * **[not](#not)** ([code](lib/comparison.js#L470) | [no tests])
137
+ * **[not](#not)** ([code](lib/comparison.js#L470) | [tests](test/comparison.js#L624))
137
138
  * **[or](#or)** ([code](lib/comparison.js#L492) | [tests](test/comparison.js#L523))
138
139
  * **[unlessEq](#unlessEq)** ([code](lib/comparison.js#L518) | [tests](test/comparison.js#L556))
139
140
  * **[unlessGt](#unlessGt)** ([code](lib/comparison.js#L538) | [tests](test/comparison.js#L567))
@@ -211,37 +212,37 @@ Visit the: [code](lib/match.js) | [unit tests](test/match.js) | [issues](https:/
211
212
 
212
213
  * **[match](#match)** ([code](lib/match.js#L23) | [tests](test/match.js#L13))
213
214
  * **[isMatch](#isMatch)** ([code](lib/match.js#L47) | [tests](test/match.js#L61))
214
- * **[mm](#mm)** ([code](lib/match.js#L56) | [no tests])
215
+ * **[mm](#mm)** ([code](lib/match.js#L56) | [tests](test/match.js#L67))
215
216
 
216
217
  ### [math helpers](#math)
217
218
 
218
219
  Visit the: [code](lib/math.js) | [unit tests](test/math.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+math+helpers))
219
220
 
220
- * **[abs](#abs)** ([code](lib/math.js#L15) | [no tests])
221
+ * **[abs](#abs)** ([code](lib/math.js#L15) | [test](test/math.js#L149))
221
222
  * **[add](#add)** ([code](lib/math.js#L31) | [tests](test/math.js#L10))
222
- * **[avg](#avg)** ([code](lib/math.js#L54) | [no tests])
223
+ * **[avg](#avg)** ([code](lib/math.js#L54) | [tests](test/math.js#L25))
223
224
  * **[ceil](#ceil)** ([code](lib/math.js#L69) | [tests](test/math.js#L29))
224
225
  * **[divide](#divide)** ([code](lib/math.js#L84) | [tests](test/math.js#L36))
225
226
  * **[floor](#floor)** ([code](lib/math.js#L102) | [tests](test/math.js#L43))
226
- * **[minus](#minus)** ([code](lib/math.js#L118) | [no tests])
227
- * **[modulo](#modulo)** ([code](lib/math.js#L137) | [no tests])
227
+ * **[minus](#minus)** ([code](lib/math.js#L118) | [tests](test/math.js#L169))
228
+ * **[modulo](#modulo)** ([code](lib/math.js#L137) | [tests](test/math.js#L191))
228
229
  * **[multiply](#multiply)** ([code](lib/math.js#L157) | [tests](test/math.js#L50))
229
- * **[plus](#plus)** ([code](lib/math.js#L175) | [no tests])
230
+ * **[plus](#plus)** ([code](lib/math.js#L175) | [tests](test/math.js#L231))
230
231
  * **[random](#random)** ([code](lib/math.js#L194) | [tests](test/math.js#L102))
231
232
  * **[remainder](#remainder)** ([code](lib/math.js#L212) | [tests](test/math.js#L57))
232
233
  * **[round](#round)** ([code](lib/math.js#L224) | [tests](test/math.js#L69))
233
234
  * **[subtract](#subtract)** ([code](lib/math.js#L241) | [tests](test/math.js#L76))
234
235
  * **[sum](#sum)** ([code](lib/math.js#L263) | [tests](test/math.js#L83))
235
- * **[times](#times)** ([code](lib/math.js#L286) | [no tests])
236
+ * **[times](#times)** ([code](lib/math.js#L286) | [tests](test/math.js#L299))
236
237
 
237
238
  ### [misc helpers](#misc)
238
239
 
239
240
  Visit the: [code](lib/misc.js) | [unit tests](test/misc.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+misc+helpers))
240
241
 
241
- * **[frame](#frame)** ([code](lib/misc.js#L11) | [no tests])
242
+ * **[frame](#frame)** ([code](lib/misc.js#L11) | [tests](test/misc.js#L1))
242
243
  * **[option](#option)** ([code](lib/misc.js#L26) | [tests](test/misc.js#L20))
243
244
  * **[noop](#noop)** ([code](lib/misc.js#L39) | [tests](test/misc.js#L13))
244
- * **[typeOf](#typeOf)** ([code](lib/misc.js#L59) | [no tests])
245
+ * **[typeOf](#typeOf)** ([code](lib/misc.js#L59) | [tests](test/misc.js#L38))
245
246
  * **[withHash](#withHash)** ([code](lib/misc.js#L71) | [tests](test/misc.js#L38))
246
247
 
247
248
  ### [number helpers](#number)
@@ -287,21 +288,21 @@ Visit the: [code](lib/path.js) | [unit tests](test/path.js) | [issues](https://g
287
288
  * **[basename](#basename)** ([code](lib/path.js#L81) | [tests](test/path.js#L47))
288
289
  * **[stem](#stem)** ([code](lib/path.js#L100) | [tests](test/path.js#L58))
289
290
  * **[extname](#extname)** ([code](lib/path.js#L119) | [tests](test/path.js#L69))
290
- * **[resolve](#resolve)** ([code](lib/path.js#L138) | [no tests])
291
+ * **[resolve](#resolve)** ([code](lib/path.js#L138) | [tests](test/path.js#L145))
291
292
  * **[segments](#segments)** ([code](lib/path.js#L166) | [tests](test/path.js#L80))
292
293
 
293
294
  ### [regex helpers](#regex)
294
295
 
295
296
  Visit the: [code](lib/regex.js) | [unit tests](test/regex.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+regex+helpers))
296
297
 
297
- * **[toRegex](#toRegex)** ([code](lib/regex.js#L19) | [no tests])
298
- * **[test](#test)** ([code](lib/regex.js#L42) | [no tests])
298
+ * **[toRegex](#toRegex)** ([code](lib/regex.js#L19) | [tests](test/regex.js#10))
299
+ * **[test](#test)** ([code](lib/regex.js#L42) | [tests](test/regex.js#15))
299
300
 
300
301
  ### [string helpers](#string)
301
302
 
302
303
  Visit the: [code](lib/string.js) | [unit tests](test/string.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+string+helpers))
303
304
 
304
- * **[append](#append)** ([code](lib/string.js#L22) | [no tests])
305
+ * **[append](#append)** ([code](lib/string.js#L22) | [tests](test/string.js#L9))
305
306
  * **[camelcase](#camelcase)** ([code](lib/string.js#L41) | [tests](test/string.js#L10))
306
307
  * **[capitalize](#capitalize)** ([code](lib/string.js#L60) | [tests](test/string.js#L25))
307
308
  * **[capitalizeAll](#capitalizeAll)** ([code](lib/string.js#L77) | [tests](test/string.js#L36))
@@ -309,7 +310,7 @@ Visit the: [code](lib/string.js) | [unit tests](test/string.js) | [issues](https
309
310
  * **[chop](#chop)** ([code](lib/string.js#L125) | [tests](test/string.js#L58))
310
311
  * **[dashcase](#dashcase)** ([code](lib/string.js#L143) | [tests](test/string.js#L73))
311
312
  * **[dotcase](#dotcase)** ([code](lib/string.js#L162) | [tests](test/string.js#L88))
312
- * **[downcase](#downcase)** ([code](lib/string.js#L182) | [no tests])
313
+ * **[downcase](#downcase)** ([code](lib/string.js#L182) | [tests](test/string.js#L391))
313
314
  * **[ellipsis](#ellipsis)** ([code](lib/string.js#L202) | [tests](test/string.js#L103))
314
315
  * **[hyphenate](#hyphenate)** ([code](lib/string.js#L223) | [tests](test/string.js#L118))
315
316
  * **[isString](#isString)** ([code](lib/string.js#L240) | [tests](test/string.js#L129))
@@ -318,12 +319,12 @@ Visit the: [code](lib/string.js) | [unit tests](test/string.js) | [issues](https
318
319
  * **[pascalcase](#pascalcase)** ([code](lib/string.js#L303) | [tests](test/string.js#L173))
319
320
  * **[pathcase](#pathcase)** ([code](lib/string.js#L323) | [tests](test/string.js#L188))
320
321
  * **[plusify](#plusify)** ([code](lib/string.js#L343) | [tests](test/string.js#L203))
321
- * **[prepend](#prepend)** ([code](lib/string.js#L363) | [no tests])
322
- * **[raw](#raw)** ([code](lib/string.js#L385) | [no tests])
323
- * **[remove](#remove)** ([code](lib/string.js#L413) | [no tests])
324
- * **[removeFirst](#removeFirst)** ([code](lib/string.js#L432) | [no tests])
322
+ * **[prepend](#prepend)** ([code](lib/string.js#L363) | [tests](test/string.js#L409))
323
+ * **[raw](#raw)** ([code](lib/string.js#L385) | [tests](test/string.js#L465))
324
+ * **[remove](#remove)** ([code](lib/string.js#L413) | [tests](test/string.js#L416)
325
+ * **[removeFirst](#removeFirst)** ([code](lib/string.js#L432) | [tests](test/string.js#L422))
325
326
  * **[replace](#replace)** ([code](lib/string.js#L452) | [tests](test/string.js#L222))
326
- * **[replaceFirst](#replaceFirst)** ([code](lib/string.js#L473) | [no tests])
327
+ * **[replaceFirst](#replaceFirst)** ([code](lib/string.js#L473) | [tests](test/string.js#L428))
327
328
  * **[reverse](#reverse)** ([code](lib/string.js#L492) | [tests](test/string.js#L241))
328
329
  * **[sentence](#sentence)** ([code](lib/string.js#L509) | [tests](test/string.js#L252))
329
330
  * **[snakecase](#snakecase)** ([code](lib/string.js#L528) | [tests](test/string.js#L263))
@@ -331,11 +332,11 @@ Visit the: [code](lib/string.js) | [unit tests](test/string.js) | [issues](https
331
332
  * **[startsWith](#startsWith)** ([code](lib/string.js#L572) | [tests](test/string.js#L293))
332
333
  * **[titleize](#titleize)** ([code](lib/string.js#L596) | [tests](test/string.js#L312))
333
334
  * **[trim](#trim)** ([code](lib/string.js#L623) | [tests](test/string.js#L323))
334
- * **[trimLeft](#trimLeft)** ([code](lib/string.js#L639) | [no tests])
335
- * **[trimRight](#trimRight)** ([code](lib/string.js#L657) | [no tests])
335
+ * **[trimLeft](#trimLeft)** ([code](lib/string.js#L639) | [tests](test/string.js#L436))
336
+ * **[trimRight](#trimRight)** ([code](lib/string.js#L657) | [tests](test/string.js#L441))
336
337
  * **[truncate](#truncate)** ([code](lib/string.js#L680) | [tests](test/string.js#L338))
337
- * **[truncateWords](#truncateWords)** ([code](lib/string.js#L712) | [no tests])
338
- * **[upcase](#upcase)** ([code](lib/string.js#L742) | [no tests])
338
+ * **[truncateWords](#truncateWords)** ([code](lib/string.js#L712) | [tests](test/string.js#L447)))
339
+ * **[upcase](#upcase)** ([code](lib/string.js#L742) | [tests](test/string.js#458))
339
340
  * **[uppercase](#uppercase)** ([code](lib/string.js#L763) | [tests](test/string.js#L362))
340
341
 
341
342
  ### [url helpers](#url)
@@ -343,14 +344,14 @@ Visit the: [code](lib/string.js) | [unit tests](test/string.js) | [issues](https
343
344
  Visit the: [code](lib/url.js) | [unit tests](test/url.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+url+helpers))
344
345
 
345
346
  * **[encodeURI](#encodeURI)** ([code](lib/url.js#L19) | [tests](test/url.js#L31))
346
- * **[escape](#escape)** ([code](lib/url.js#L34) | [no tests])
347
+ * **[escape](#escape)** ([code](lib/url.js#L34) | [tests](test/url.js#L81))
347
348
  * **[decodeURI](#decodeURI)** ([code](lib/url.js#L48) | [tests](test/url.js#L38))
348
- * **[url_encode](#url_encode)** ([code](lib/url.js#L59) | [no tests])
349
- * **[url_decode](#url_decode)** ([code](lib/url.js#L68) | [no tests])
349
+ * **[url_encode](#url_encode)** ([code](lib/url.js#L59) | [tests](test/url.js#L89))
350
+ * **[url_decode](#url_decode)** ([code](lib/url.js#L68) | [tests](test/url.js#L93))
350
351
  * **[urlResolve](#urlResolve)** ([code](lib/url.js#L82) | [tests](test/url.js#L11))
351
352
  * **[urlParse](#urlParse)** ([code](lib/url.js#L94) | [tests](test/url.js#L45))
352
353
  * **[stripQuerystring](#stripQuerystring)** ([code](lib/url.js#L106) | [tests](test/url.js#L24))
353
- * **[stripProtocol](#stripProtocol)** ([code](lib/url.js#L126) | [no tests])
354
+ * **[stripProtocol](#stripProtocol)** ([code](lib/url.js#L126) | [tests](test/url.js#L53))
354
355
 
355
356
  ***
356
357
 
package/index.d.ts CHANGED
@@ -1,16 +1,3 @@
1
1
  // index.d.ts
2
-
3
- // Importing types from the handlebars package
4
- import { Handlebars } from 'handlebars';
5
-
6
- // Assuming helpers.js exports a function. Adjust as needed.
7
- interface HelpersFunction {
8
- (config: { handlebars: typeof Handlebars }): void;
9
- }
10
-
11
- // Since you're exporting the handlebars instance itself:
12
- declare const handlebars: typeof Handlebars;
13
-
14
- export = handlebars;
15
-
16
-
2
+ import * as Handlebars from 'handlebars';
3
+ export = Handlebars;
package/lib/math.js CHANGED
@@ -32,9 +32,6 @@ helpers.add = function(a, b) {
32
32
  if (isNumber(a) && isNumber(b)) {
33
33
  return Number(a) + Number(b);
34
34
  }
35
- if (typeof a === 'string' && typeof b === 'string') {
36
- return a + b;
37
- }
38
35
  return '';
39
36
  };
40
37
 
package/lib/path.js CHANGED
@@ -5,6 +5,15 @@ var path = require('path');
5
5
  var utils = require('./utils');
6
6
  var helpers = module.exports;
7
7
 
8
+ utils.expectedType = (variableName, expectedType, variableValue) => {
9
+ const actualType = Object.prototype.toString.call(variableValue).slice(8, -1).toLowerCase();
10
+
11
+ if (actualType !== expectedType) {
12
+ throw new TypeError(`Expected ${variableName} to be of type ${expectedType}, but got ${actualType}`);
13
+ }
14
+ };
15
+
16
+
8
17
  /**
9
18
  * Get the directory path segment from the given `filepath`.
10
19
  *
package/lib/regex.js CHANGED
@@ -43,7 +43,7 @@ helpers.test = function(str, regex) {
43
43
  if (!util.isString(str)) {
44
44
  return false;
45
45
  }
46
- if (!utils.typeOf(regex) === 'regexp') {
46
+ if (utils.typeOf(regex) !== 'regexp') {
47
47
  throw new TypeError('expected a regular expression');
48
48
  }
49
49
  return regex.test(str);
package/lib/string.js CHANGED
@@ -460,7 +460,7 @@ helpers.replace = function(str, a, b) {
460
460
  * Replace the first occurrence of substring `a` with substring `b`.
461
461
  *
462
462
  * ```handlebars
463
- * {{replace "a b a b a b" "a" "z"}}
463
+ * {{replaceFirst "a b a b a b" "a" "z"}}
464
464
  * <!-- results in: 'z b a b a b' -->
465
465
  * ```
466
466
  * @param {String} `str`
@@ -695,9 +695,9 @@ helpers.truncate = function(str, limit, suffix) {
695
695
  *
696
696
  * ```handlebars
697
697
  * truncateWords("foo bar baz", 1);
698
- * <!-- results in: 'foo…' -->
698
+ * <!-- results in: 'foo...' -->
699
699
  * truncateWords("foo bar baz", 2);
700
- * <!-- results in: 'foo bar…' -->
700
+ * <!-- results in: 'foo bar...' -->
701
701
  * truncateWords("foo bar baz", 3);
702
702
  * <!-- results in: 'foo bar baz' -->
703
703
  * ```
@@ -712,12 +712,12 @@ helpers.truncate = function(str, limit, suffix) {
712
712
  helpers.truncateWords = function(str, count, suffix) {
713
713
  if (util.isString(str) && isNumber(count)) {
714
714
  if (typeof suffix !== 'string') {
715
- suffix = '…';
715
+ suffix = '...';
716
716
  }
717
717
 
718
718
  var num = Number(count);
719
- var arr = str.split(/[ \t]/);
720
- if (num > arr.length) {
719
+ var arr = str.split(' ');
720
+ if (num < arr.length) {
721
721
  arr = arr.slice(0, num);
722
722
  }
723
723
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jaredwray/fumanchu",
3
3
  "description": "Handlebars + Helpers = Fumanchu",
4
- "version": "1.0.2",
4
+ "version": "1.0.3",
5
5
  "homepage": "https://github.com/jaredwray/fumanchu",
6
6
  "author": "Jared Wray (me@jaredwray.com)",
7
7
  "keywords": [
@@ -97,15 +97,13 @@
97
97
  "source": "index.js",
98
98
  "main": "index.js",
99
99
  "types": "index.d.ts",
100
- "browser": "dist/fumanchu.min.js",
101
100
  "engines": {
102
101
  "node": ">=14"
103
102
  },
104
103
  "scripts": {
105
104
  "test": "c8 mocha --reporter list",
106
105
  "test:ci": "c8 --reporter=lcov mocha --reporter list",
107
- "build": "parcel build --dist-dir dist",
108
- "clean": "rm -rf node_modules && rm -rf dist && rm -rf .parcel-cache"
106
+ "clean": "rm -rf node_modules && rm -rf coverage"
109
107
  },
110
108
  "dependencies": {
111
109
  "arr-flatten": "^1.1.0",
@@ -138,22 +136,10 @@
138
136
  "year": "^0.2.1"
139
137
  },
140
138
  "devDependencies": {
141
- "@parcel/watcher": "^2.3.0",
142
139
  "c8": "^8.0.1",
143
140
  "chai": "^4.3.8",
144
- "global-modules": "^2.0.0",
145
141
  "mocha": "^10.2.0",
146
- "parcel": "^2.9.3",
147
142
  "template-helpers": "^1.0.1",
148
143
  "templates": "^1.2.9"
149
- },
150
- "browserslist": [
151
- "last 1 version",
152
- "> 1%",
153
- "not dead"
154
- ],
155
- "targets": {
156
- "main": false,
157
- "types": false
158
144
  }
159
145
  }