# @esm2cjs/onetime

> Ensure a function is only called once. This is a fork of sindresorhus/onetime, but with CommonJS support.

Latest version **6.0.1-cjs.0** (published 2022-08-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @esm2cjs/onetime
pnpm add @esm2cjs/onetime
yarn add @esm2cjs/onetime
bun add @esm2cjs/onetime
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.0.1-cjs.0 |
| Published | 2022-08-18 |
| First published | 2022-08-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=12 |
| Dependencies | 1 |
| Unpacked size | 10.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dominic Griesel |
| Maintainers | alcalzone |
| Keywords | once, function, one, onetime, func, fn, single, call, called, prevent |

## Links

- npm: https://www.npmjs.com/package/@esm2cjs/onetime
- Repository: https://github.com/esm2cjs/onetime
- Homepage: https://github.com/esm2cjs/onetime#readme
- Issues: https://github.com/esm2cjs/onetime/issues
- Funding: https://github.com/sponsors/AlCalzone
- npm.io page: https://npm.io/package/@esm2cjs/onetime

## Dependencies (1)

- [@esm2cjs/mimic-fn](https://npm.io/package/@esm2cjs/mimic-fn.md) ^4.0.0

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 6.0.1-cjs.0 (latest) — 2022-08-18
- 6.0.0 — 2022-08-18

## README

# @esm2cjs/onetime

This is a fork of https://github.com/sindresorhus/onetime, but automatically patched to support ESM **and** CommonJS, unlike the original repository.

## Install

You can use an npm alias to install this package under the original name:

```
npm i onetime@npm:@esm2cjs/onetime
```

```jsonc
// package.json
"dependencies": {
    "onetime": "npm:@esm2cjs/onetime"
}
```

but `npm` might dedupe this incorrectly when other packages depend on the replaced package. If you can, prefer using the scoped package directly:

```
npm i @esm2cjs/onetime
```

```jsonc
// package.json
"dependencies": {
    "@esm2cjs/onetime": "^ver.si.on"
}
```

> **Note:**
> We strive to use the same versions as the upstream package, but unfortunately there is a bit of a learning curve with these things.
> As a result, we had to re-publish `6.0.0` as `6.0.1-cjs.0`.

## Usage

```js
// Using ESM import syntax
import onetime from "onetime";

// Using CommonJS require()
const onetime = require("onetime").default;
```

> **Note:**
> Because the original module uses `export default`, you need to append `.default` to the `require()` call.

For more details, please see the original [repository](https://github.com/sindresorhus/onetime).

## Sponsoring

To support my efforts in maintaining the ESM/CommonJS hybrid, please sponsor [here](https://github.com/sponsors/AlCalzone).

To support the original author of the module, please sponsor [here](https://github.com/sindresorhus/onetime).

---
_Source: https://npm.io/package/@esm2cjs/onetime · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
