Skip to content

Replace with function #2

@yanickrochon

Description

@yanickrochon

String.prototype.replace accepts a function as second argument. Whereas this module force the second argument to be a string. There should be a check and, if "to" is of type function, then let it be.

Example :

b.transform(browserifyReplace, {
  'replace': [{
    'from': LIBRARY_PATTERN_TOKENS,
      'to': function (match, token, old) {
        return 'lib.config["' + token + '"]';
      }
  }]
});

But instead of having lib.config["foo"], I have a .toString() of that function.

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