Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / onetime / index.d.ts
index d39c42d961db4109a1bc71cd5c984761285d4b93..ea84caba320c862cb25ae7b4808588bb27939314 100644 (file)
@@ -1,4 +1,4 @@
-declare namespace oneTime {
+declare namespace onetime {
        interface Options {
                /**
                Throw an error when called more than once.
@@ -9,16 +9,31 @@ declare namespace oneTime {
        }
 }
 
-declare const oneTime: {
+declare const onetime: {
        /**
        Ensure a function is only called once. When called multiple times it will return the return value from the first call.
 
        @param fn - Function that should only be called once.
        @returns A function that only calls `fn` once.
+
+       @example
+       ```
+       import onetime = require('onetime');
+
+       let i = 0;
+
+       const foo = onetime(() => ++i);
+
+       foo(); //=> 1
+       foo(); //=> 1
+       foo(); //=> 1
+
+       onetime.callCount(foo); //=> 3
+       ```
        */
        <ArgumentsType extends unknown[], ReturnType>(
                fn: (...arguments: ArgumentsType) => ReturnType,
-               options?: oneTime.Options
+               options?: onetime.Options
        ): (...arguments: ArgumentsType) => ReturnType;
 
        /**
@@ -43,7 +58,7 @@ declare const oneTime: {
        callCount(fn: (...arguments: any[]) => unknown): number;
 
        // TODO: Remove this for the next major release
-       default: typeof oneTime;
+       default: typeof onetime;
 };
 
-export = oneTime;
+export = onetime;