-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
144 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# EditorConfig: http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# 2 space indentation | ||
[*.yaml, *.yml] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Global | ||
node_modules/ | ||
|
||
# OS Generated | ||
.DS_Store* | ||
ehthumbs.db | ||
Icon? | ||
Thumbs.db | ||
*.swp | ||
|
||
# phpstorm | ||
.idea/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<a name="1.0.0"></a> | ||
# [1.0.0](https://github.com/faker-javascript/string) (2022-01-08) | ||
* Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,40 @@ | ||
# string | ||
<h1 align="center">String</h1> | ||
<p align="center"> | ||
String package provides functionality to generate a fake string value. | ||
</p> | ||
|
||
<p align="center"> | ||
<a href="https://github.com/faker-javascript/string/releases"><img alt="Version" src="https://img.shields.io/github/release/faker-javascript/string.svg?label=version&color=green"></a> <a href="https://github.com/faker-javascript/string"><img src="https://img.shields.io/badge/license-MIT-blue.svg?color=green" alt="License"></a> <img src="https://github.com/faker-javascript/string/actions/workflows/tests.yml/badge.svg"> | ||
|
||
## Install | ||
|
||
``` | ||
$ npm install --save @fakerjs/string | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
import fakeString from '@fakerjs/string'; | ||
|
||
fakeString(); | ||
//=> 3Kekravwvb78vP9CQPP1vaRCgi4dZETOktxzf8pF5gufFqh8mOICMqjRP4y8UxoI | ||
|
||
fakeString(10); | ||
//=> FxvqHNFNUu | ||
|
||
fakeString(10, '#@$%&+='); | ||
//=> $+#%#&$$=@ | ||
``` | ||
|
||
## Tests | ||
|
||
Run tests | ||
|
||
``` | ||
npm run test | ||
``` | ||
|
||
## License | ||
[The MIT License (MIT)](https://github.com/faker-javascript/string/blob/master/LICENSE.txt) | ||
Copyright (c) [Sergey Romanenko](https://github.com/Awilum) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default function fakeString(length = 64, keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') { | ||
let pieces = []; | ||
if (length < 0) { | ||
length = 1; | ||
} | ||
for (var i = 0; i < length; i++) { | ||
pieces.push(keyspace.charAt(Math.floor(Math.random() * keyspace.length))); | ||
} | ||
return pieces.join(''); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "@fakerjs/string", | ||
"version": "1.0.0", | ||
"description": "String package provides functionality to generate a fake string value.", | ||
"license": "MIT", | ||
"repository": "fakerjs/string", | ||
"author": { | ||
"name": "Sergey Romanenko", | ||
"email": "[email protected]", | ||
"url": "https://github.com/Awilum" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=12" | ||
}, | ||
"scripts": { | ||
"test": "ava" | ||
}, | ||
"devDependencies": { | ||
"ava": "^3.15.0" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"fakerjs", | ||
"fake", | ||
"random", | ||
"strings", | ||
"string", | ||
"str" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import fakeString from './index.js'; | ||
import test from 'ava'; | ||
|
||
test('fakeString return type to be string', t => { | ||
t.is(typeof fakeString(), 'string'); | ||
}); | ||
|
||
test('fakeString string length is 10', t => { | ||
t.is(fakeString(10).length, 10); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Tests | ||
on: ['push', 'pull_request'] | ||
jobs: | ||
test: | ||
name: Node.js ${{ matrix.node-version }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: [^12, ^14, ^16, ^17] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm install | ||
- run: npm test |