• Version 0.8.1
  • Published
  • 10.1 kB
  • No dependencies
  • MIT license


npm i assert-options
yarn add assert-options
pnpm add assert-options


Generic options parameter handling.



variable assertOptions

const assertOptions: AssertFunc;
  • Default options-assert function.


function createAssert

createAssert: (errHandler: IOptionsErrorHandler) => AssertFunc;
  • Creates an options-assert function that uses specified error handler.


class DefaultErrorHandler

class DefaultErrorHandler implements IOptionsErrorHandler {}
  • Default handler for options-related issues.

method handle

handle: (err: OptionsError, ctx: IOptionsErrorContext) => NamedValues;


    interface IOptionsErrorContext

    interface IOptionsErrorContext {}
    • Error-related context available for options-related issues.

    property defaults

    defaults: any;

      property key

      key?: string;

        property options

        options: any;

          interface IOptionsErrorHandler

          interface IOptionsErrorHandler {}

            method handle

            handle: (err: OptionsError, ctx: IOptionsErrorContext) => NamedValues;
            • This method is normally expected to throw an error, based on "err"


            enum OptionsError

            enum OptionsError {
            invalidOptionsParam = 0,
            invalidDefaultsParam = 1,
            optionNotRecognized = 2,
            • All errors that can occur inside an assert function.

            member invalidDefaultsParam

            invalidDefaultsParam = 1

              member invalidOptionsParam

              invalidOptionsParam = 0

                member optionNotRecognized

                optionNotRecognized = 2

                  Type Aliases

                  type AssertFunc

                  type AssertFunc = (
                  options: NamedValues | null | undefined,
                  defaults: NamedValues | string[]
                  ) => NamedValues;
                  • Assert function signature.

                  type NamedValues

                  type NamedValues = {
                  [name: string]: any;
                  • Standard syntax for named values.

                  Package Files (4)

                  Dependencies (0)

                  No dependencies.

                  Dev Dependencies (10)

                  Peer Dependencies (0)

                  No peer dependencies.


                  To add a badge like this badgeto your package's README, use the codes available below.

                  You may also use to create a custom badge linking to

                  • Markdown
                  • HTML
                    <a href=""><img src="" alt=""></a>