@jaredwray/fumanchu 3.0.0 → 3.0.1

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,4 +1,4 @@
1
- ![Fumanchu](logo.png "Fumanchu")
1
+ ![Fumanchu](site/logo.svg "Fumanchu")
2
2
 
3
3
 
4
4
  # fumanchu
@@ -14,11 +14,11 @@ Handlebars + Helpers Together
14
14
 
15
15
  We plan to make significant changes over time with this project such as the following:
16
16
  - **(Completed)** Remove all dependencies on `handlebars-helpers` and maintain all helpers in this project
17
+ - **(Completed)** Migration to `vitest` as a testing framework
18
+ - **(Completed)** Migration to `xo` as a linting framework
17
19
  - **(In Progress)** Migrate to Typescript with full typing support
18
20
  - **(In Progress)** Replace module dependencies that are no longer supported with supported ones
19
21
  - Migration to ESM and CJS support using cross compatible code
20
- - Migration to `vitest` as a testing framework
21
- - Migration to `xo` as a linting framework
22
22
  - Move to better documentation and examples where it makes sense
23
23
  - Add in browser support via CDN (this will remove the nodejs specific helpers)
24
24
 
@@ -3098,6 +3098,8 @@ Generate a random number
3098
3098
  ## How to Contribute
3099
3099
  clone the repository locally and run 'npm i' in the root. Now that you've set up your workspace, you're ready to contribute changes to the `fumanchu` repository you can refer to the [CONTRIBUTING](CONTRIBUTING.md) guide. If you have any questions please feel free to ask by creating an issue and label it `question`.
3100
3100
 
3101
+ To test the legacy helpers, you can run `npm run test:legacy` to run the tests. If you want to test the new helpers, you can run `npm run test`.
3102
+
3101
3103
  ## License and Copyright
3102
3104
  [MIT](LICENSE) and codebase after 2023 will be copyright of Jared Wray.
3103
3105
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,15 @@
1
1
  import * as HandlebarsLib from 'handlebars';
2
2
 
3
+ declare enum HelperRegistryCompatibility {
4
+ NODEJS = "nodejs",
5
+ BROWSER = "browser"
6
+ }
7
+ type HelperFilter = {
8
+ name?: string;
9
+ category?: string;
10
+ compatibility?: HelperRegistryCompatibility;
11
+ };
12
+
3
13
  /**
4
14
  * Handlebars library not initiated with helpers
5
15
  * @type {Handlebars}
@@ -22,5 +32,33 @@ declare const helpers: {
22
32
  * @returns {Promise<Handlebars>}
23
33
  */
24
34
  declare function createHandlebars(): Promise<typeof HandlebarsLib>;
35
+ /**
36
+ * @typedef {Object} FumanchuCachingOptions
37
+ * @property {number|string} [ttl] - Time to Live - If you set a number it is miliseconds, if you set a string it is a human-readable
38
+ * format such as `1s` for 1 second or `1h` for 1 hour. Setting undefined means that it will use the default time-to-live. If both are
39
+ * undefined then it will not have a time-to-live.
40
+ * @property {boolean} [useClone] - If true, it will clone the value before returning it. If false, it will return the value directly. Default is true.
41
+ * @property {number} [lruSize] - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0.
42
+ * @property {number} [checkInterval] - The interval to check for expired items. If set to 0, it will not check for expired items. Default is 0.
43
+ */
44
+ type FumanchuCachingOptions = {
45
+ ttl?: number | string;
46
+ useClone?: boolean;
47
+ lruSize?: number;
48
+ checkInterval?: number;
49
+ };
50
+ type FumanchuOptions = {
51
+ handlebars?: typeof HandlebarsLib;
52
+ helpers?: Record<string, Function>;
53
+ name?: string | string[];
54
+ include?: HelperFilter[];
55
+ exclude?: HelperFilter[];
56
+ caching?: boolean | FumanchuCachingOptions;
57
+ };
58
+ /**
59
+ * Will return a Handlebars instance with Fumanchu helpers (experimental)
60
+ * @returns {Handlebars} Handlebars instance with helpers
61
+ */
62
+ declare function fumanchu(options?: FumanchuOptions): typeof HandlebarsLib;
25
63
 
26
- export { Handlebars, createHandlebars, handlebars, helpers };
64
+ export { type FumanchuCachingOptions, type FumanchuOptions, Handlebars, createHandlebars, fumanchu, handlebars, helpers };