Skip to content

Commit a43a524

Browse files
committed
feat(core): initial code commit
1 parent 066845c commit a43a524

File tree

9 files changed

+144
-2
lines changed

9 files changed

+144
-2
lines changed

.editorconfig

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# EditorConfig: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
charset = utf-8
9+
end_of_line = lf
10+
trim_trailing_whitespace = true
11+
insert_final_newline = true
12+
indent_style = space
13+
indent_size = 4
14+
15+
# 2 space indentation
16+
[*.yaml, *.yml]
17+
indent_style = space
18+
indent_size = 2

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Global
2+
node_modules/
3+
4+
# OS Generated
5+
.DS_Store*
6+
ehthumbs.db
7+
Icon?
8+
Thumbs.db
9+
*.swp
10+
11+
# phpstorm
12+
.idea/*

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<a name="1.0.0"></a>
2+
# [1.0.0](https://github.com/faker-javascript/string) (2022-01-08)
3+
* Initial release

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 Faker Javascript
3+
Copyright (c) Sergey Romanenko
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+39-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,40 @@
1-
# string
1+
<h1 align="center">String</h1>
2+
<p align="center">
23
String package provides functionality to generate a fake string value.
4+
</p>
5+
6+
<p align="center">
7+
<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">
8+
9+
## Install
10+
11+
```
12+
$ npm install --save @fakerjs/string
13+
```
14+
15+
## Usage
16+
17+
```js
18+
import fakeString from '@fakerjs/string';
19+
20+
fakeString();
21+
//=> 3Kekravwvb78vP9CQPP1vaRCgi4dZETOktxzf8pF5gufFqh8mOICMqjRP4y8UxoI
22+
23+
fakeString(10);
24+
//=> FxvqHNFNUu
25+
26+
fakeString(10, '#@$%&+=');
27+
//=> $+#%#&$$=@
28+
```
29+
30+
## Tests
31+
32+
Run tests
33+
34+
```
35+
npm run test
36+
```
37+
38+
## License
39+
[The MIT License (MIT)](https://github.com/faker-javascript/string/blob/master/LICENSE.txt)
40+
Copyright (c) [Sergey Romanenko](https://github.com/Awilum)

index.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default function fakeString(length = 64, keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') {
2+
let pieces = [];
3+
if (length < 0) {
4+
length = 1;
5+
}
6+
for (var i = 0; i < length; i++) {
7+
pieces.push(keyspace.charAt(Math.floor(Math.random() * keyspace.length)));
8+
}
9+
return pieces.join('');
10+
};

package.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "@fakerjs/string",
3+
"version": "1.0.0",
4+
"description": "String package provides functionality to generate a fake string value.",
5+
"license": "MIT",
6+
"repository": "fakerjs/string",
7+
"author": {
8+
"name": "Sergey Romanenko",
9+
"email": "[email protected]",
10+
"url": "https://github.com/Awilum"
11+
},
12+
"type": "module",
13+
"exports": "./index.js",
14+
"engines": {
15+
"node": ">=12"
16+
},
17+
"scripts": {
18+
"test": "ava"
19+
},
20+
"devDependencies": {
21+
"ava": "^3.15.0"
22+
},
23+
"files": [
24+
"index.js"
25+
],
26+
"keywords": [
27+
"fakerjs",
28+
"fake",
29+
"random",
30+
"strings",
31+
"string",
32+
"str"
33+
]
34+
}

test.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import fakeString from './index.js';
2+
import test from 'ava';
3+
4+
test('fakeString return type to be string', t => {
5+
t.is(typeof fakeString(), 'string');
6+
});
7+
8+
test('fakeString string length is 10', t => {
9+
t.is(fakeString(10).length, 10);
10+
});

workflows/tests.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Tests
2+
on: ['push', 'pull_request']
3+
jobs:
4+
test:
5+
name: Node.js ${{ matrix.node-version }}
6+
runs-on: ubuntu-latest
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
node-version: [^12, ^14, ^16, ^17]
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-node@v2
14+
with:
15+
node-version: ${{ matrix.node-version }}
16+
- run: npm install
17+
- run: npm test

0 commit comments

Comments
 (0)