Skip to content

Commit

Permalink
String 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Jan 9, 2022
1 parent fb0f426 commit 12427b3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<a name="2.0.0"></a>
# [2.0.0](https://github.com/faker-javascript/string) (2022-01-09)

### BREAKING CHANGES

* New function `string` istead of `fakeString`

<a name="1.0.1"></a>
# [1.0.1](https://github.com/faker-javascript/string) (2022-01-08)
* Package fixes
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, '#@$%&+=');
//=> $+#%#&$$=@
```

Expand Down
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -25,6 +25,7 @@
],
"keywords": [
"fakerjs",
"faker",
"fake",
"random",
"strings",
Expand Down
15 changes: 10 additions & 5 deletions test.js
Original file line number Diff line number Diff line change
@@ -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);
});

0 comments on commit 12427b3

Please sign in to comment.