A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/fent/randexp.js/commit/15eb60a below:

calling shorthand method with string (#50) · fent/randexp.js@15eb60a · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+11

-0

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+11

-0

lines changed Original file line number Diff line number Diff line change

@@ -236,6 +236,10 @@ module.exports = class RandExp {

236 236

*/

237 237

static randexp(regexp, m) {

238 238

var randexp;

239 +

if(typeof regexp === 'string') {

240 +

regexp = new RegExp(regexp, m);

241 +

}

242 + 239 243

if (regexp._randexp === undefined) {

240 244

randexp = new RandExp(regexp, m);

241 245

regexp._randexp = randexp;

Original file line number Diff line number Diff line change

@@ -53,6 +53,13 @@ describe('Call with a string', () => {

53 53

});

54 54

});

55 55 56 +

describe('Call shorthand randexp method with a string', () => {

57 +

it('Returns a correctly generated string', () => {

58 +

var r = randexp('\\d{4}');

59 +

assert.equal(r.length, 4);

60 +

});

61 +

});

62 + 56 63

describe('Call without a string or regular expression', () => {

57 64

it('Throws an error', () => {

58 65

assert.throws(() => {

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4