JSPM

@types/simple-swizzle

0.2.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5031
  • Score
    100M100P100Q130814F
  • License MIT

TypeScript definitions for simple-swizzle

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@types/simple-swizzle) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Installation

    npm install --save @types/simple-swizzle

    Summary

    This package contains type definitions for simple-swizzle (https://github.com/qix-/node-simple-swizzle).

    Details

    Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/simple-swizzle.

    index.d.ts

    export = swizzle;
    
    /**
     * [Swizzle](https://en.wikipedia.org/wiki/Swizzling_(computer_graphics)) your function arguments.
     *
     * @example
     * import swizzle = require('simple-swizzle');
     *
     * function myFunc(...args: Array<number | number[]>): number[] {
     *     const argsArr = swizzle(args);
     *     // ...
     *     return argsArr;
     * }
     *
     * myFunc(1, [2, 3], 4); // [1, 2, 3, 4]
     * myFunc(1, 2, 3, 4);   // [1, 2, 3, 4]
     * myFunc([1, 2, 3, 4]); // [1, 2, 3, 4]
     */
    declare function swizzle<TElement extends unknown>(arguments: ArrayLike<TElement | ArrayLike<TElement>>): TElement[];
    
    declare namespace swizzle {
        /**
         * Functions can also be wrapped to automatically swizzle arguments and be passed the resulting array.
         *
         * @example
         * import swizzle = require('simple-swizzle');
         *
         * const swizzledFn = swizzle.wrap((args: number[]): number[] {
         *     // ...
         *     return args;
         * });
         *
         * swizzledFn(1, [2, 3], 4); // [1, 2, 3, 4]
         * swizzledFn(1, 2, 3, 4);   // [1, 2, 3, 4]
         * swizzledFn([1, 2, 3, 4]); // [1, 2, 3, 4]
         */
        function wrap<TFn extends (arguments: any[]) => unknown>(
            fn: TFn,
        ): (
            ...args: Parameters<TFn>[0] extends Array<infer TElement> ? Array<TElement | TElement[]> : never
        ) => ReturnType<TFn>;
    }
    

    Additional Details

    • Last updated: Wed, 18 Oct 2023 11:45:06 GMT
    • Dependencies: none

    Credits

    These definitions were written by BendingBender.