diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c6272f..4a85853 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ + +# [2.0.0](https://github.com/faker-javascript/string) (2022-01-09) + +### BREAKING CHANGES + +* New function `string` istead of `fakeString` + # [1.0.1](https://github.com/faker-javascript/string) (2022-01-08) * Package fixes diff --git a/README.md b/README.md index 7d6c512..22fd028 100644 --- a/README.md +++ b/README.md @@ -15,15 +15,15 @@ $ npm install --save @fakerjs/string ## Usage ```js -import fakeString from '@fakerjs/string'; +import string from '@fakerjs/string'; -fakeString(); +string(); //=> 3Kekravwvb78vP9CQPP1vaRCgi4dZETOktxzf8pF5gufFqh8mOICMqjRP4y8UxoI -fakeString(10); +string(10); //=> FxvqHNFNUu -fakeString(10, '#@$%&+='); +string(10, '#@$%&+='); //=> $+#%#&$$=@ ``` diff --git a/index.js b/index.js index 050e23f..fa7e0e9 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,7 @@ -export default function fakeString(length = 64, keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') { +export default function string(options) { + options = options || {}; + let length = options.length || 64; + let keyspace = options.keyspace || '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; let pieces = []; if (length < 0) { length = 1; diff --git a/package.json b/package.json index ac3897f..c3cfa66 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fakerjs/string", - "version": "1.0.1", + "version": "2.0.0", "description": "String package provides functionality to generate a fake string value.", "license": "MIT", "repository": "faker-javascript/string", @@ -25,6 +25,7 @@ ], "keywords": [ "fakerjs", + "faker", "fake", "random", "strings", diff --git a/test.js b/test.js index 2b70458..b122122 100644 --- a/test.js +++ b/test.js @@ -1,10 +1,15 @@ -import fakeString from './index.js'; +import string from './index.js'; import test from 'ava'; -test('fakeString return type to be string', t => { - t.is(typeof fakeString(), 'string'); +//console.log(string({length: 10})); +test('string return type to be string', t => { + t.is(typeof string(), 'string'); }); -test('fakeString string length is 10', t => { - t.is(fakeString(10).length, 10); +test('string length is 10', t => { + t.is(string({length: 10}).length, 10); }); + +test('string length is 10 with keyspace 0123456789', t => { + t.is(string({length: 10, keyspace: '0123456789'}).length, 10); +}); \ No newline at end of file