frep
Version:
Find and replace utility for node.js. Transform strings by running multiple RegExp or string find-and-replace patterns on a string in sequence, reducing the final string to the accumulated result of each transformation. Patterns can be strings (or arrays
21 lines (18 loc) • 518 B
JavaScript
var path = require('path');
var expect = require('chai').expect;
var frep = require('../');
describe('when an array of replacement patterns is passed', function () {
it('should replace the first match.', function () {
var patterns = ['ABC', 'DEF']
var replacements = {
'A': 'AAA',
'B': 'BBB',
'C': 'CCC',
'D': 'DDD',
'E': 'EEE',
'F': 'FFF'
};
var actual = frep.arrWithObj(patterns, replacements);
expect(actual).to.eql(['AAABBBCCC', 'DDDEEEFFF']);
});
});