Skip to content

Commit

Permalink
Add formatNumber and debounce functions
Browse files Browse the repository at this point in the history
  • Loading branch information
iantrich committed Jan 27, 2021
1 parent 6c5397b commit ad87b33
Show file tree
Hide file tree
Showing 96 changed files with 426 additions and 361 deletions.
9 changes: 9 additions & 0 deletions dist/debounce.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Returns a function, that, as long as it continues to be invoked, will not be triggered. It will be called after it stops being called for `wait` ms.
* This can be usefull for ResizeObservers for example.
* @param func The function you want to debounce
* @param wait Period to wait in ms
* @param immediate Triggering on the leading edge instead of the trailing
* @returns Debounced Function
*/
export declare const debounce: <T extends (...args: any[]) => unknown>(func: T, wait: number, immediate?: boolean) => T;
6 changes: 6 additions & 0 deletions dist/format-number.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Formats a number based on the specified language with thousands separator(s) and decimal character for better legibility.
* @param num The number to format
* @param language The language to use when formatting the number
*/
export declare const formatNumber: (num: string | number, language: string, options?: Intl.NumberFormatOptions) => string;
2 changes: 2 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ export * from "./compute-state-display";
export * from "./compute-state-domain";
export * from "./const";
export * from "./create-thing";
export * from "./debounce";
export * from "./domain_icons";
export * from "./evaluate-filter";
export * from "./fire-event";
export * from "./format-number";
export * from "./handle-action";
export * from "./handle-click";
export * from "./haptic";
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.m.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.m.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.umd.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/assets/js/search.json

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions docs/globals.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ <h3>Modules</h3>
<li class="tsd-kind-module"><a href="modules/_datetime_relative_time_.html" class="tsd-kind-icon">&quot;datetime/relative_<wbr>time&quot;</a></li>
<li class="tsd-kind-module"><a href="modules/_datetime_seconds_to_duration_.html" class="tsd-kind-icon">&quot;datetime/seconds_<wbr>to_<wbr>duration&quot;</a></li>
<li class="tsd-kind-module"><a href="modules/_datetime_timer_time_remaining_.html" class="tsd-kind-icon">&quot;datetime/timer_<wbr>time_<wbr>remaining&quot;</a></li>
<li class="tsd-kind-module"><a href="modules/_debounce_.html" class="tsd-kind-icon">&quot;debounce&quot;</a></li>
<li class="tsd-kind-module"><a href="modules/_domain_icons_.html" class="tsd-kind-icon">&quot;domain_<wbr>icons&quot;</a></li>
<li class="tsd-kind-module"><a href="modules/_evaluate_filter_.html" class="tsd-kind-icon">&quot;evaluate-<wbr>filter&quot;</a></li>
<li class="tsd-kind-module"><a href="modules/_fire_event_.html" class="tsd-kind-icon">&quot;fire-<wbr>event&quot;</a></li>
<li class="tsd-kind-module"><a href="modules/_format_number_.html" class="tsd-kind-icon">&quot;format-<wbr>number&quot;</a></li>
<li class="tsd-kind-module"><a href="modules/_get_lovelace_.html" class="tsd-kind-icon">&quot;get-<wbr>lovelace&quot;</a></li>
<li class="tsd-kind-module"><a href="modules/_handle_action_.html" class="tsd-kind-icon">&quot;handle-<wbr>action&quot;</a></li>
<li class="tsd-kind-module"><a href="modules/_handle_click_.html" class="tsd-kind-icon">&quot;handle-<wbr>click&quot;</a></li>
Expand Down Expand Up @@ -176,6 +178,9 @@ <h3>Modules</h3>
<li class=" tsd-kind-module">
<a href="modules/_datetime_timer_time_remaining_.html">&quot;datetime/timer_<wbr>time_<wbr>remaining&quot;</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_debounce_.html">&quot;debounce&quot;</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_domain_icons_.html">&quot;domain_<wbr>icons&quot;</a>
</li>
Expand All @@ -185,6 +190,9 @@ <h3>Modules</h3>
<li class=" tsd-kind-module">
<a href="modules/_fire_event_.html">&quot;fire-<wbr>event&quot;</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_format_number_.html">&quot;format-<wbr>number&quot;</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_get_lovelace_.html">&quot;get-<wbr>lovelace&quot;</a>
</li>
Expand Down
6 changes: 6 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ <h1>custom-card-helpers</h1>
<li class=" tsd-kind-module">
<a href="modules/_datetime_timer_time_remaining_.html">&quot;datetime/timer_<wbr>time_<wbr>remaining&quot;</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_debounce_.html">&quot;debounce&quot;</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_domain_icons_.html">&quot;domain_<wbr>icons&quot;</a>
</li>
Expand All @@ -143,6 +146,9 @@ <h1>custom-card-helpers</h1>
<li class=" tsd-kind-module">
<a href="modules/_fire_event_.html">&quot;fire-<wbr>event&quot;</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_format_number_.html">&quot;format-<wbr>number&quot;</a>
</li>
<li class=" tsd-kind-module">
<a href="modules/_get_lovelace_.html">&quot;get-<wbr>lovelace&quot;</a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion docs/interfaces/_fire_event_.hassdomevent.html
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ <h3>detail</h3>
<div class="tsd-signature tsd-kind-icon">detail<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">T</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/638f528/src/fire-event.ts#L39">src/fire-event.ts:39</a></li>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/6c5397b/src/fire-event.ts#L39">src/fire-event.ts:39</a></li>
</ul>
</aside>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ <h3>haptic</h3>
<div class="tsd-signature tsd-kind-icon">haptic<span class="tsd-signature-symbol">:</span> <a href="_fire_event_.hassdomevent.html" class="tsd-signature-type">HASSDomEvent</a><span class="tsd-signature-symbol">&lt;</span><a href="../modules/_haptic_.html#haptictype" class="tsd-signature-type">HapticType</a><span class="tsd-signature-symbol">&gt;</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/638f528/src/haptic.ts#L27">src/haptic.ts:27</a></li>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/6c5397b/src/haptic.ts#L27">src/haptic.ts:27</a></li>
</ul>
</aside>
</section>
Expand Down
2 changes: 1 addition & 1 deletion docs/interfaces/_haptic_.__global.hassdomevents.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ <h3>haptic</h3>
<div class="tsd-signature tsd-kind-icon">haptic<span class="tsd-signature-symbol">:</span> <a href="../modules/_haptic_.html#haptictype" class="tsd-signature-type">HapticType</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/638f528/src/haptic.ts#L23">src/haptic.ts:23</a></li>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/6c5397b/src/haptic.ts#L23">src/haptic.ts:23</a></li>
</ul>
</aside>
</section>
Expand Down
2 changes: 1 addition & 1 deletion docs/interfaces/_navigate_.__global.hassdomevents.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ <h3>location-<wbr>changed</h3>
<div class="tsd-signature tsd-kind-icon">location-<wbr>changed<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{ </span>replace<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol"> }</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/638f528/src/navigate.ts#L6">src/navigate.ts:6</a></li>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/6c5397b/src/navigate.ts#L6">src/navigate.ts:6</a></li>
</ul>
</aside>
<div class="tsd-type-declaration">
Expand Down
6 changes: 3 additions & 3 deletions docs/interfaces/_translations_localize_.formatstype.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ <h3>date</h3>
<div class="tsd-signature tsd-kind-icon">date<span class="tsd-signature-symbol">:</span> <a href="_translations_localize_.formattype.html" class="tsd-signature-type">FormatType</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/638f528/src/translations/localize.ts#L11">src/translations/localize.ts:11</a></li>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/6c5397b/src/translations/localize.ts#L11">src/translations/localize.ts:11</a></li>
</ul>
</aside>
</section>
Expand All @@ -110,7 +110,7 @@ <h3>number</h3>
<div class="tsd-signature tsd-kind-icon">number<span class="tsd-signature-symbol">:</span> <a href="_translations_localize_.formattype.html" class="tsd-signature-type">FormatType</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/638f528/src/translations/localize.ts#L10">src/translations/localize.ts:10</a></li>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/6c5397b/src/translations/localize.ts#L10">src/translations/localize.ts:10</a></li>
</ul>
</aside>
</section>
Expand All @@ -120,7 +120,7 @@ <h3>time</h3>
<div class="tsd-signature tsd-kind-icon">time<span class="tsd-signature-symbol">:</span> <a href="_translations_localize_.formattype.html" class="tsd-signature-type">FormatType</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/638f528/src/translations/localize.ts#L12">src/translations/localize.ts:12</a></li>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/6c5397b/src/translations/localize.ts#L12">src/translations/localize.ts:12</a></li>
</ul>
</aside>
</section>
Expand Down
16 changes: 8 additions & 8 deletions docs/interfaces/_types_.__global.hassdomevents.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ <h3>action</h3>
<div class="tsd-signature tsd-kind-icon">action<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{ </span>action<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> }</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/638f528/src/types.ts#L123">src/types.ts:123</a></li>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/6c5397b/src/types.ts#L123">src/types.ts:123</a></li>
</ul>
</aside>
<div class="tsd-type-declaration">
Expand All @@ -126,7 +126,7 @@ <h3>config-<wbr>changed</h3>
<div class="tsd-signature tsd-kind-icon">config-<wbr>changed<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{ </span>config<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol"> }</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/638f528/src/types.ts#L111">src/types.ts:111</a></li>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/6c5397b/src/types.ts#L111">src/types.ts:111</a></li>
</ul>
</aside>
<div class="tsd-type-declaration">
Expand All @@ -144,7 +144,7 @@ <h3>hass-<wbr>more-<wbr>info</h3>
<div class="tsd-signature tsd-kind-icon">hass-<wbr>more-<wbr>info<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{ </span>entityId<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> }</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/638f528/src/types.ts#L114">src/types.ts:114</a></li>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/6c5397b/src/types.ts#L114">src/types.ts:114</a></li>
</ul>
</aside>
<div class="tsd-type-declaration">
Expand All @@ -162,7 +162,7 @@ <h3>ll-<wbr>rebuild</h3>
<div class="tsd-signature tsd-kind-icon">ll-<wbr>rebuild<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{}</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/638f528/src/types.ts#L117">src/types.ts:117</a></li>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/6c5397b/src/types.ts#L117">src/types.ts:117</a></li>
</ul>
</aside>
<div class="tsd-type-declaration">
Expand All @@ -177,7 +177,7 @@ <h3>location-<wbr>changed</h3>
<div class="tsd-signature tsd-kind-icon">location-<wbr>changed<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{ </span>replace<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol"> }</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/638f528/src/types.ts#L118">src/types.ts:118</a></li>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/6c5397b/src/types.ts#L118">src/types.ts:118</a></li>
</ul>
</aside>
<div class="tsd-type-declaration">
Expand All @@ -195,7 +195,7 @@ <h3>show-<wbr>dialog</h3>
<div class="tsd-signature tsd-kind-icon">show-<wbr>dialog<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{}</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/638f528/src/types.ts#L121">src/types.ts:121</a></li>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/6c5397b/src/types.ts#L121">src/types.ts:121</a></li>
</ul>
</aside>
<div class="tsd-type-declaration">
Expand All @@ -210,7 +210,7 @@ <h3>undefined</h3>
<div class="tsd-signature tsd-kind-icon">undefined<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/638f528/src/types.ts#L122">src/types.ts:122</a></li>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/6c5397b/src/types.ts#L122">src/types.ts:122</a></li>
</ul>
</aside>
</section>
Expand All @@ -220,7 +220,7 @@ <h3>value-<wbr>changed</h3>
<div class="tsd-signature tsd-kind-icon">value-<wbr>changed<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{ </span>value<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol"> }</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/638f528/src/types.ts#L108">src/types.ts:108</a></li>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/6c5397b/src/types.ts#L108">src/types.ts:108</a></li>
</ul>
</aside>
<div class="tsd-type-declaration">
Expand Down
2 changes: 1 addition & 1 deletion docs/interfaces/_types_.actionhandlerdetail.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ <h3>action</h3>
<div class="tsd-signature tsd-kind-icon">action<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/638f528/src/types.ts#L288">src/types.ts:288</a></li>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/6c5397b/src/types.ts#L288">src/types.ts:288</a></li>
</ul>
</aside>
</section>
Expand Down
4 changes: 2 additions & 2 deletions docs/interfaces/_types_.actionhandleroptions.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ <h3><span class="tsd-flag ts-flagOptional">Optional</span> has<wbr>Double<wbr>Cl
<div class="tsd-signature tsd-kind-icon">has<wbr>Double<wbr>Click<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/638f528/src/types.ts#L295">src/types.ts:295</a></li>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/6c5397b/src/types.ts#L295">src/types.ts:295</a></li>
</ul>
</aside>
</section>
Expand All @@ -109,7 +109,7 @@ <h3><span class="tsd-flag ts-flagOptional">Optional</span> has<wbr>Hold</h3>
<div class="tsd-signature tsd-kind-icon">has<wbr>Hold<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/638f528/src/types.ts#L294">src/types.ts:294</a></li>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/6c5397b/src/types.ts#L294">src/types.ts:294</a></li>
</ul>
</aside>
</section>
Expand Down
2 changes: 1 addition & 1 deletion docs/interfaces/_types_.baseactionconfig.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ <h3><span class="tsd-flag ts-flagOptional">Optional</span> confirmation</h3>
<div class="tsd-signature tsd-kind-icon">confirmation<span class="tsd-signature-symbol">:</span> <a href="_types_.confirmationrestrictionconfig.html" class="tsd-signature-type">ConfirmationRestrictionConfig</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/638f528/src/types.ts#L69">src/types.ts:69</a></li>
<li>Defined in <a href="https://github.com/custom-cards/custom-card-helpers/blob/6c5397b/src/types.ts#L69">src/types.ts:69</a></li>
</ul>
</aside>
</section>
Expand Down
Loading

0 comments on commit ad87b33

Please sign in to comment.