Back to Explore

isaacs/once

GitHub
3 watchersOpen source

Last release:

A small JavaScript utility that wraps a function so it runs exactly once, caching the first return value for later calls. Useful for preventing duplicate callbacks in event-driven code, and it also provides a `once.strict` variant that throws an error if the function is called more than one time.

Project status

  • The source does not appear to be actively maintained as of 2026-09-10, with the latest available tagged update (v1.4.1) dated 2022-02-27, and no newer update information shown in the provided history (though the repo has an upstream push on 2025-10-25).
  • Apparent update cadence is very infrequent, with large gaps between known updates (v1.4.1 in 2022, v1.4.0 in 2016, then earlier versions stretching back years), which suggests a maintenance or low-velocity trajectory rather than regular iteration.

AI summary generated

AI-generated from public sources. May be inaccurate. Report

Recent updates

  • v1.4.1

    v1.4.1 appears to be a small release with no publisher-provided release notes. The code changes are limited, but there is a potentially user-facing change around how the proto helper is exported, plus tooling and CI updates and a devDependency upgrade.

  • v1.4.0

    v1.4.0 introduces a new strict variant of the `once` wrapper, `once.strict`, intended to throw an error if the wrapped function is called more than once. It also exposes `Function.prototype.onceStrict` for the same behavior.

    Features
  • v1.3.3

    Release v1.3.3 was published on 2015-11-20, but no release notes were provided by the publisher. As a result, there is no stated information about new features, fixes, security updates, or migration steps in the available data.

  • v1.3.2

    Release v1.3.2 contains only metadata and license changes, with no observable runtime or API code modifications in the provided diff. The only substantive change is switching the project license from BSD to ISC and updating the corresponding license field in package.json.

    Breaking
  • v1.3.1

    This release (v1.3.1) makes a small implementation change to the `once` module and adds a new runtime dependency. No release notes were provided, so the documented change list is empty.

  • v1.3.0

    Release v1.3.0 changes the runtime behavior of the `once` wrapper so that it caches the original function's return value. Subsequent calls now return the cached value via a new `fn.value` property, rather than returning `undefined`.

    BreakingFeatures
  • v1.2.0

    This release adds support for checking whether the wrapped function has been called by exposing a `called` boolean on the returned wrapper function. There is no release-note content provided, so the change is effectively undocumented externally. The core once-only behavior remains, but the wrapper function now carries new observable state.

    Features
  • v1.1.1

    Release v1.1.1 was published, but the publisher did not provide any release notes. As a result, there is no documented information about new features, bug fixes, breaking changes, or dependency updates in this release.