Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fails with es6 class member functions #26

Copy link
Copy link
@psnider

Description

@psnider
Issue body actions

version 0.4.0
node v6.9.1

When I enter this code in the node REPL:

var promisify = require("promisify-node");
class C {
    constructor() {
        this.promisified_connect = promisify(this.connect);
    }
    connect(done) {
        if (done) {
            done();
        } else {
            return this.promisified_connect();
        }
    }
}
var c = new C()

promisify-node throws this error:

TypeError: Cannot read property '1' of null
    at module.exports (./node_modules/promisify-node/utils/args.js:9:63)
    at processExports (./node_modules/promisify-node/index.js:61:29)
    at module.exports (./node_modules/promisify-node/index.js:164:10)

so I updated the RegExp in https://github.com/nodegit/promisify-node/blob/master/utils/args.js#L9 from:

/function\s.*?\(([^)]*)\)/

to:

/\(([^)]*)\)/

Then re-running the above test code produced another error:

TypeError: Cannot convert undefined or null to object
    at processExports (./node_modules/promisify-node/index.js:86:16)
    at module.exports (./node_modules/promisify-node/index.js:164:10)
    at new C (repl:3:28)

I was able to get past this by modifying https://github.com/nodegit/promisify-node/blob/master/index.js#L86 to guard the checking of the keys of the prototype to:

    if (exports.prototype) {
      if (Object.keys(exports.prototype).length) {

I believe there are likely other changes required.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.