Skip to content

Functions should be bound to context or not use this #2

@Yomguithereal

Description

@Yomguithereal

Hello @acarl005. The fact that your functions need this to function has this somewhat uncomfortable side-effect that you cannot use them without calling them from the generatorics object.

Here is what I mean:

// If you do the following for instance:
var combination = require('generatorics').combination;

// This will throw & fail because the function does not have the required scope
combination([1, 2, 3], 2);

A solution would be to bind your function to the correct scope before exporting or rewrite the code marginally not to rely on the scope of the generatorics object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions