Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: thenables/thenify
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: node-opcua/thenify-ex
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 17 commits
  • 18 files changed
  • 1 contributor

Commits on Jan 26, 2025

  1. Copy the full SHA
    1c037c3 View commit details
  2. port to typescript

    erossignon committed Jan 26, 2025
    Copy the full SHA
    a0fdeea View commit details
  3. wip github action

    erossignon committed Jan 26, 2025
    Copy the full SHA
    1259e2a View commit details
  4. Copy the full SHA
    21c56b8 View commit details
  5. wip github action2

    erossignon committed Jan 26, 2025
    Copy the full SHA
    f0c7dd4 View commit details
  6. Copy the full SHA
    27e209d View commit details
  7. rename to thenify2

    erossignon committed Jan 26, 2025
    Copy the full SHA
    281981d View commit details
  8. rename to thenify2

    erossignon committed Jan 26, 2025
    Copy the full SHA
    21ed089 View commit details
  9. find alternate name

    erossignon committed Jan 26, 2025
    Copy the full SHA
    79602d9 View commit details
  10. Release 4.0.0

    erossignon committed Jan 26, 2025
    Copy the full SHA
    e42709b View commit details
  11. fix up package.json

    erossignon committed Jan 26, 2025
    Copy the full SHA
    48c7e01 View commit details
  12. Release 4.1.0

    erossignon committed Jan 26, 2025
    Copy the full SHA
    d637c40 View commit details
  13. add typescript test

    erossignon committed Jan 26, 2025
    Copy the full SHA
    2729572 View commit details
  14. Release 4.2.0

    erossignon committed Jan 26, 2025
    Copy the full SHA
    e752376 View commit details

Commits on Jan 27, 2025

  1. update README

    erossignon committed Jan 27, 2025
    Copy the full SHA
    35fde3a View commit details
  2. update package.json

    erossignon committed Jan 27, 2025
    Copy the full SHA
    5830ae6 View commit details
  3. Merge pull request #1 from node-opcua/update

    switch from travis to github actions
    erossignon authored Jan 27, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    4687240 View commit details
Showing with 3,739 additions and 204 deletions.
  1. +27 −0 .github/workflows/workflow.yaml
  2. +5 −0 .gitignore
  3. +12 −0 .mocharc.yml
  4. +7 −0 .prettierrc
  5. +0 −9 .travis.yml
  6. +9 −6 History.md
  7. +42 −28 README.md
  8. +0 −77 index.js
  9. +3,293 −0 package-lock.json
  10. +33 −12 package.json
  11. +86 −0 src/index.ts
  12. +24 −21 test/options.js
  13. +18 −17 test/promisify.js
  14. +29 −28 test/test.js
  15. +24 −0 test/test_typescript.ts
  16. +8 −6 test/withcallback.js
  17. +112 −0 tsconfig.json
  18. +10 −0 tsup.config.ts
27 changes: 27 additions & 0 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run build
- run: npm run test

5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -5,3 +5,8 @@

node_modules
coverage
index.d.ts
index.d.ts.map
index.js
index.js.map
dist
12 changes: 12 additions & 0 deletions .mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
recursive: true
require:
- should
- ts-node/register
timeout: 20000
enable-source-maps: true
extension:
- .ts
- .js
bail: true
parallel: false
jobs: 32
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"useTabs": false,
"printWidth": 80,
"tabWidth": 2,
"semi": false,
"singleQuote": true
}
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

15 changes: 9 additions & 6 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# 4.0.0 / 20245-01-26

3.3.1 / 2020-06-18
==================
port to ESM /CommonJS dual module, use Typescript


# 3.3.1 / 2020-06-18

**fixes**
* [[`0d94a24`](http://github.com/thenables/thenify/commit/0d94a24eb933bc835d568f3009f4d269c4c4c17a)] - fix: remove eval (#30) (Yiyu He <<dead_horse@qq.com>>)

3.3.0 / 2017-05-19
==================
- [[`0d94a24`](http://github.com/thenables/thenify/commit/0d94a24eb933bc835d568f3009f4d269c4c4c17a)] - fix: remove eval (#30) (Yiyu He <<dead_horse@qq.com>>)

# 3.3.0 / 2017-05-19

* feat: support options.multiArgs and options.withCallback (#27)
- feat: support options.multiArgs and options.withCallback (#27)
70 changes: 42 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# thenify-ex

A fork of [thenify](thenify-url) to support modern CJS/ESM modules with typescript support.


# thenify

[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Build status][github-action-image]][github-action-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![Dependency Status][david-image]][david-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]

@@ -22,6 +24,7 @@ An added benefit is that `throw`n errors in that async function will be caught b

### fn = thenify(fn, options)


Promisifies a function.

### Options
@@ -30,41 +33,46 @@ Promisifies a function.

- `options.withCallback` - support both callback and promise style, default to `false`.
- `options.multiArgs` - change the behavior when callback have multiple arguments. default to `true`.

- `true` - converts multiple arguments to an array
- `false`- always use the first argument
- `Array` - converts multiple arguments to an object with keys provided in `options.multiArgs`

- Turn async functions into promises


```js
var thenify = require('thenify');
import { thenify } from 'thenify';

var somethingAsync = thenify(function somethingAsync(a, b, c, callback) {
callback(null, a, b, c);
});
const somethingAsync = thenify(function somethingAsync(a, b, c, callback) {
callback(null, a, b, c)
})
```

- Backward compatible with callback

```js
var thenify = require('thenify');
import { thenify } from 'thenify';

var somethingAsync = thenify(function somethingAsync(a, b, c, callback) {
callback(null, a, b, c);
}, { withCallback: true });
const somethingAsync = thenify(
function somethingAsync(a, b, c, callback) {
callback(null, a, b, c)
},
{ withCallback: true },
)

// somethingAsync(a, b, c).then(onFulfilled).catch(onRejected);
// somethingAsync(a, b, c, function () {});
```

or use `thenify.withCallback()`
or use `withCallback()`

```js
var thenify = require('thenify').withCallback;
import { withCallback} from "thenify";

var somethingAsync = thenify(function somethingAsync(a, b, c, callback) {
callback(null, a, b, c);
});
var somethingAsync = withCallback(function somethingAsync(a, b, c, callback) {
callback(null, a, b, c)
})

// somethingAsync(a, b, c).then(onFulfilled).catch(onRejected);
// somethingAsync(a, b, c, function () {});
@@ -73,11 +81,14 @@ var somethingAsync = thenify(function somethingAsync(a, b, c, callback) {
- Always return the first argument in callback

```js
var thenify = require('thenify');
import { thenify} from "thenify";

var promise = thenify(function (callback) {
callback(null, 1, 2, 3);
}, { multiArgs: false });
var promise = thenify(
function (callback) {
callback(null, 1, 2, 3)
},
{ multiArgs: false },
)

// promise().then(function onFulfilled(value) {
// assert.equal(value, 1);
@@ -87,11 +98,14 @@ var promise = thenify(function (callback) {
- Converts callback arguments to an object

```js
var thenify = require('thenify');
import { thenify} from "thenify";

var promise = thenify(function (callback) {
callback(null, 1, 2, 3);
}, { multiArgs: [ 'one', 'tow', 'three' ] });
var promise = thenify(
function (callback) {
callback(null, 1, 2, 3)
},
{ multiArgs: ['one', 'tow', 'three'] },
)

// promise().then(function onFulfilled(value) {
// assert.deepEqual(value, {
@@ -102,19 +116,19 @@ var promise = thenify(function (callback) {
// });
```

[github-action-image]: https://github.com/node-opcua/thenify2/actions/workflows/workflow.yaml/badge.svg
[github-action-url]: https://github.com/node-opcua/thenify2/actions
[gitter-image]: https://badges.gitter.im/thenables/thenify.png
[gitter-url]: https://gitter.im/thenables/thenify
[npm-image]: https://img.shields.io/npm/v/thenify.svg?style=flat-square
[npm-url]: https://npmjs.org/package/thenify
[github-tag]: http://img.shields.io/github/tag/thenables/thenify.svg?style=flat-square
[github-url]: https://github.com/thenables/thenify/tags
[travis-image]: https://img.shields.io/travis/thenables/thenify.svg?style=flat-square
[travis-url]: https://travis-ci.org/thenables/thenify
[coveralls-image]: https://img.shields.io/coveralls/thenables/thenify.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/thenables/thenify
[david-image]: http://img.shields.io/david/thenables/thenify.svg?style=flat-square
[david-url]: https://david-dm.org/thenables/thenify
[license-image]: http://img.shields.io/npm/l/thenify.svg?style=flat-square
[license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/thenify.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/thenify
[downloads-image]: http://img.shields.io/npm/dm/thenify-ex.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/thenify-ex
77 changes: 0 additions & 77 deletions index.js

This file was deleted.

Loading