npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@typedly/settings

v0.3.0

Published

A TypeScript type definitions package for settings.

Readme

typedly/settings

npm version GitHub issues GitHub license

Version: v0.3.0

A TypeScript type definitions package for settings.

Table of contents

Installation

Install peer dependencies

npm install @typedly/length @typedly/pattern --save-peer

Install the package

npm install @typedly/settings --save-peer

Api

// Interface.
import {
  // Value.
  ValueSetting,
  // Settings.
  Settings,
} from '@typedly/settings';

// Type.
import {
  // Settings.
  DisplaySelectedSettings,
  SelectableSettings,
  // Settings fields.
  OptionalField,
  RequiredField,
} from '@typedly/settings'; 

Interface

ValueSetting

value-setting.interface.ts

import { ValueSetting } from '@typedly/settings';

export const valueSettings: ValueSetting<'the value'> = {
  value: 'the value'
}

Settings

settings.interface.ts

import { Settings } from '@typedly/settings';

export const settings: Settings<
  'abcd1234',
  number,
  27,
  34,
  RegExp
> = {
  // LengthSettings
  length: { min: 27, max: 34 },
  // PatternSettings
  pattern: {
    lowercase: true,
    numeric: true,
    regexp: /[a]g/g,
    special: true,
    uppercase: true,
  },
  // ValueSettings
  value: 'abcd1234',
}

Type

DisplaySelectedSettings

display-selected-settings.type.ts

import { DisplaySelectedSettings } from '@typedly/settings';

OptionalField

optional-field.type.ts

import { OptionalField } from '@typedly/settings';

RequiredField

required-field.type.ts

import { RequiredField } from '@typedly/settings';

SelectableSettings

selectable-settings.type.ts

import { SelectableSettings } from '@typedly/settings';

export const settings: SelectableSettings<
  ['length', 'value'],
  'abcd1234',
  number,
  27,
  34,
  RegExp
> = {
  // LengthSettings
  length: { min: 27, max: 34 },
  // PatternSettings - not allowed
  // pattern: {
  //   lowercase: true,
  //   numeric: true,
  //   regexp: /[a]g/g,
  //   special: true,
  //   uppercase: true,
  // },
  // ValueSettings
  value: 'abcd1234',
}

Configuration System Overview

This library uses a structured approach for handling settings, options, and configuration, ensuring strong typing and clarity, as follows.

Naming Convention for Settings Interfaces

To promote clarity and consistency, the following naming conventions for settings interfaces are used:

  • Singular (Setting): Represents a single, specific configuration option.

    • Example:
      LengthSetting describes the settings for a single aspect, such as the allowed length of a value.
      • MinLengthSetting describes the minimum length requirement.
      • MaxLengthSetting describes the maximum length requirement.
  • Plural (Settings): Represents a group of related settings, often an object containing multiple Setting properties.

    • Example:
      LengthSettings groups together related settings, such as both minimum and maximum length requirements:
export interface LengthSettings {
  min: MinLengthSetting;
  max: MaxLengthSetting;
}
export interface LengthSetting {
  length: LengthSettings;
}

Summary Table

| Name | Meaning | Example Usage | |--------------------|----------------------------------------|----------------------------------------------| | LengthSetting | Single setting (e.g., length) | const min: LengthSetting = { ... } | | MinLengthSetting | Specific single setting (min length) | const min: MinLengthSetting = { ... } | | LengthSettings | Group of related settings (plural) | const settings: LengthSettings = { ... } |

Settings

Settings types define the shape of configuration data with all fields required at the top level, but can be omitted by setting them to undefined. They represent the complete set of parameters that can be provided, ensuring that all necessary information is present. The settings may include option objects whose own fields can be optional, even though top-level field in the settings is required, but may be set to undefined.

  • Represents the “full shape” of what can be configured.
  • Used for validation, documentation, or generating configuration forms.
  • Unlike Options, Settings ensure every possible field is present, event if unset.

Example:

// Represents the concrete settings for a length configuration.
export interface Length<
  Value extends number | undefined = number | undefined,
  Min extends number | undefined = number | undefined,
  Max extends number | undefined = number | undefined
> {
  /**
   * @description Represents expected length of the value, also between min and max.
   * @type {Value}
   */
  value: Value;

  /**
   * @description Represents the minimum length of the value.
   * @type {Min}
   */
  min: Min;

  /**
   * @description Represents the maximum length of the value.
   * @type {Max}
   */
  max: Max;
}

Options

Options types are based on the corresponding settings, but make all or some fields optional.
Use options when you want to allow partial configuration, for example for incremental setup or user input that may not specify all values.

Example:

export interface LengthOptions<
  Value extends number | undefined = number | undefined,
  Min extends number | undefined = number | undefined,
  Max extends number | undefined = number | undefined
> extends OptionalField<Length<Value, Min, Max>> {}

Configuration

Configuration types represent the result of applying/saving settings and options.
They often reflect the actual configuration that is active at runtime, possibly after defaults and validation have been applied.

Example:

export type LengthConfiguration = LengthSettings;

Summary Table

| Type | Fields Required? | Usage | |---------------|-------------------|-------------------------------------------| | Settings | All | Full specification of settings | | Options | Some/All optional | Partial or user-provided configuration | | Configuration | All (finalized) | Saved, validated, or runtime configuration|

Contributing

Your contributions are valued! If you'd like to contribute, please feel free to submit a pull request. Help is always appreciated.

Support

If you find this package useful and would like to support its and general development, you can contribute through one of the following payment methods. Your support helps maintain the packages and continue adding new.

Support via:

or via Trust Wallet

Thanks for your support!

Code of Conduct

By participating in this project, you agree to follow Code of Conduct.

GIT

Commit

Versioning

Semantic Versioning 2.0.0

Given a version number MAJOR.MINOR.PATCH, increment the:

  • MAJOR version when you make incompatible API changes,
  • MINOR version when you add functionality in a backwards-compatible manner, and
  • PATCH version when you make backwards-compatible bug fixes.

Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.

FAQ How should I deal with revisions in the 0.y.z initial development phase?

The simplest thing to do is start your initial development release at 0.1.0 and then increment the minor version for each subsequent release.

How do I know when to release 1.0.0?

If your software is being used in production, it should probably already be 1.0.0. If you have a stable API on which users have come to depend, you should be 1.0.0. If you’re worrying a lot about backwards compatibility, you should probably already be 1.0.0.

License

MIT © typedly (license)