Skip to content

Commit

Permalink
Refactor package to generators and ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Dec 12, 2023
1 parent bdb6e46 commit 20e9874
Show file tree
Hide file tree
Showing 11 changed files with 3,578 additions and 12,587 deletions.
12 changes: 0 additions & 12 deletions .eslintrc.js

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI
on:
- push
- pull_request
jobs:
test:
name: Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- "16"
- "*"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm test
- uses: codecov/codecov-action@v1
with:
name: Node.js ${{ matrix.node-version }}
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

27 changes: 7 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# Defer

[![NPM version][npm-image]][npm-url]
[![NPM downloads][downloads-image]][downloads-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![Bundle size][bundlephobia-image]][bundlephobia-url]

> Tiny, type-safe, JavaScript-native `defer` implementation.
**Why?** It's helpful to have statements that can automatically execute when a function has completed. For example, to `close` a file descriptor or clear state.
Expand All @@ -23,13 +17,17 @@ import { defer, deferSync } from "@borderless/defer";

let i = 0;

const fn = defer((defer) => {
defer(() => {
const fn = defer(async function* () {
const result = await doSomethingAsync();

yield () => {
i++;
expect(i).toEqual(1);
});
};

expect(i).toEqual(0);

return result;
});

await fn(); // `i == 1`.
Expand All @@ -40,14 +38,3 @@ If you're working with synchronous functions, you can use `deferSync` instead.
## License

MIT

[npm-image]: https://img.shields.io/npm/v/@borderless/defer.svg?style=flat
[npm-url]: https://npmjs.org/package/@borderless/defer
[downloads-image]: https://img.shields.io/npm/dm/@borderless/defer.svg?style=flat
[downloads-url]: https://npmjs.org/package/@borderless/defer
[travis-image]: https://img.shields.io/travis/com/borderless/defer.svg?style=flat
[travis-url]: https://travis-ci.com/github/borderless/defer
[coveralls-image]: https://img.shields.io/coveralls/borderless/defer.svg?style=flat
[coveralls-url]: https://coveralls.io/r/borderless/defer?branch=master
[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/@borderless/defer.svg
[bundlephobia-url]: https://bundlephobia.com/result?p=@borderless/defer
Loading

0 comments on commit 20e9874

Please sign in to comment.