Skip to content

Commit f17e4af

Browse files
authored
Merge pull request #32 from full-pack/1.0.0-dev
2 parents e46c215 + c7f9c8a commit f17e4af

File tree

14 files changed

+488
-1298
lines changed

14 files changed

+488
-1298
lines changed

README.md

Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ A lightweight and versatile String Utility Package for Node.js & Browser.
99
<img src="https://user-images.githubusercontent.com/6517308/121813242-859a9700-cc6b-11eb-99c0-49e5bb63005b.jpg">
1010

1111
# Contents
12+
1213
* [Install](#install)
1314
* [require](#require)
1415
* [import](#import)
@@ -37,14 +38,11 @@ A lightweight and versatile String Utility Package for Node.js & Browser.
3738
* [isAlpha](#isalpha)
3839
* [isAlphaNumeric](#isalphanumeric)
3940
* [reverse](#reverse)
40-
41-
(Coming Soon)
42-
* [StringBuilder](#)
43-
* [StringValidator](#)
4441
* [Build](#build)
4542
* [License](#license)
4643

47-
## install
44+
## Install
45+
4846
```sh
4947
npm install @full-pack/string-pack
5048
```
@@ -61,13 +59,16 @@ const { ... } = require('@full-pack/string-pack');
6159
import { ... } from '@full-pack/string-pack';
6260
```
6361

64-
## API
62+
## APIs
63+
64+
### Padding
6565

66-
### padding
6766
Adds padding to given string.
6867

6968
##### padStart
69+
7070
Pads the start of a string with a specified fill string a certain number of times.
71+
7172
```js
7273
// Basic Usage
7374
padStart('hello', 'abc', 3) // abcabcabchello
@@ -77,7 +78,9 @@ padStart('hello', 'abc', 3, 8) // abchello
7778
```
7879

7980
##### padEnd
81+
8082
Pads the end of a string with a specified fill string a certain number of times.
83+
8184
```js
8285
// Basic Usage
8386
padEnd('hello', 'abc', 3); // helloabcabcabc
@@ -87,20 +90,25 @@ padEnd('hello', 'abc', 3, 8); // helloabc
8790
```
8891

8992
##### padBidirectional
93+
9094
Pads a string with a specified fill string a certain number of times on both ends.
95+
9196
```js
9297
// Basic usage
93-
padBidirectional('hello', '*', 2); // '**hello**'
98+
padBidirectional('hello', '*', {repeatCount: 2}); // '**hello**'
9499

95100
// Limiting total length
96-
padBidirectional('world', '-', 3, 10); // '--world---'
101+
padBidirectional('world', '-', {repeatCount: 3, maxLen: 10}); // '--world---'
97102

98103
// Controlling padding distribution
99-
padBidirectional('example', '*', 2, 10, 0); // '**example*'
104+
padBidirectional('example', '*', {repeatCount: 2, maxLen: 10, bias: PaddingBias.START});
105+
// '**example*'
100106
```
101107

102108
### merge
109+
103110
Merges an array of strings into a single string using a specified separator.
111+
104112
```js
105113
merge('-', 'apple', 'orange', 'banana'); // 'apple-orange-banana'
106114

@@ -110,31 +118,39 @@ merge(false, 'apple', 'orange', 'banana'); // 'appleorangebanana'
110118
```
111119

112120
### compare
121+
113122
Performs a strict comparison between two strings.
123+
114124
```js
115125
compare("hello", "hello"); // true
116126

117127
compare("abc", "ABC"); // false
118128
```
119129

120130
### looseCompare
131+
121132
Performs a case-insensitive loose comparison between two strings.
133+
122134
```js
123135
looseCompare("hello", "HELLO"); // true
124136

125137
looseCompare('abc', '123'); // false
126138
```
127139

128140
### capitalizeInitial
141+
129142
Capitalizes the first letter of a word in a string.
143+
130144
```js
131145
capitalizeInitial('hello'); // 'Hello'
132146

133147
capitalizeInitial(':> hello'); // ':> Hello'
134148
```
135149

136150
### capitalizeWords
151+
137152
Capitalizes the first letter of each word in a given string.
153+
138154
```js
139155
capitalizeWords('hello world'); // 'Hello World'
140156

@@ -144,31 +160,39 @@ capitalizeWords('Sphinx of black quartz:-judge my vow'); // 'Sphinx Of Black Qua
144160
### Case Conversion
145161

146162
#### snakeCase
163+
147164
Converts a string to snake_case format.
165+
148166
```js
149167
snakeCase('hello WorLd'); // 'hello_world'
150168
snakeCase('from-kebab-case'); // 'from_kebab_case'
151169
snakeCase('snake Case With Numbers123', true); // 'snake_case_with_numbers_one_two_three'
152170
```
153171

154172
#### kebabCase
173+
155174
Converts a string to kebab-case format.
175+
156176
```js
157177
kebabCase('h3llo WoRld'); // 'h3llo-world'
158178
kebabCase('from_snake_case'); // 'from-snake-case'
159179
kebabCase('kebab Case With Numbers123', true); // 'kebab-case-with-numbers-one-two-three'
160180
```
161181

162182
#### camelCase
183+
163184
Converts a string to camelCase format.
185+
164186
```js
165187
camelCase('hello WoRld'); // 'helloWorld'
166188
camelCase('Test CaSe ExamplE'); // 'testCaseExample'
167189
camelCase('camel Case With Numbers123'); // 'camelCaseWithNumbers'
168190
```
169191

170192
#### pascalCase
193+
171194
Converts a string to PascalCase format.
195+
172196
```js
173197
pascalCase('hello WoRld'); // 'HelloWorld'
174198
pascalCase('Test CaSe ExamplE'); // 'TestCaseExample'
@@ -178,7 +202,9 @@ pascalCase('pasCal Case With Numbers123'); // 'PascalCaseWithNumbers'
178202
### Case Validation
179203

180204
#### isSnakeCase
205+
181206
Checks if a string is in snake_case format.
207+
182208
```js
183209
// Valid
184210
isSnakeCase('snake_case_example'); // true
@@ -195,7 +221,9 @@ isSnakeCase('no_CAPS'); // false
195221
```
196222

197223
#### isKebabCase
224+
198225
Checks if a string is in kebab-case format.
226+
199227
```js
200228
// Valid
201229
isKebabCase('kebab-case-example'); // true
@@ -212,7 +240,9 @@ isKebabCase('no-CAPS'); // false
212240
```
213241

214242
#### isCamelCase
243+
215244
Checks if a string is in camelCase format.
245+
216246
```js
217247
// Valid
218248
isCamelCase('camelCaseExample'); // true
@@ -225,7 +255,9 @@ isCamelCase('withThe1234'); // false
225255
```
226256

227257
#### isPascalCase
258+
228259
Checks if a string is in PascalCase format.
260+
229261
```js
230262
// Valid
231263
isPascalCase('PascalCaseExample'); // true
@@ -238,7 +270,9 @@ isPascalCase('WithThe1234'); // false
238270
```
239271

240272
### regionMatch
273+
241274
Compares two strings or regions for equality.
275+
242276
```js
243277
// Matching identical strings
244278
regionMatch('hello', 'hello'); // true
@@ -255,7 +289,9 @@ regionMatch('hello world', 'hello there', 6, 11); // false
255289
```
256290

257291
### looseRegionMatch
292+
258293
Performs a loose comparison of two strings or regions for equality.
294+
259295
```js
260296
// Loose matching identical strings
261297
looseRegionMatch('hello', 'HeLLo'); // true
@@ -267,29 +303,39 @@ looseRegionMatch(str1, str2); // true
267303
```
268304

269305
### isAlpha
306+
270307
Checks if a string contains only alphabetic characters (A-Z, a-z).
308+
271309
```js
272310
isAlpha("HelloWorld"); // true
273311
isAlpha("Hello123"); // false
274312
```
275313

276314
### isAlphaNumeric
315+
277316
Checks if a string contains only alphanumeric characters (A-Z, a-z, 0-9).
317+
278318
```js
279319
isAlphaNumeric("Hello01"); // true
280320
isAlphaNumeric("1234567890"); // false
281321
```
282322

283323
### Reverse
324+
284325
Reverses the sequence of characters in given string.
326+
285327
```js
286328
reverse('bad') // 'dab'
287329
```
288330

331+
Full documentation [here](https://full-pack.github.io/string-pack)
332+
289333
## Build
334+
290335
```
291336
npm run build
292337
```
293338

294339
## License
340+
295341
The MIT License. Full License is [here](LICENSE)

eslint.config.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
'use strict'
22

3+
import { defineConfig, globalIgnores } from 'eslint/config'
34
import stylistic from '@stylistic/eslint-plugin'
45
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
56
import jest from 'eslint-plugin-jest'
67
import love from 'eslint-config-love'
78

8-
export default [
9+
export default defineConfig([
10+
globalIgnores(['dist/', '**/*.js']),
911
{
10-
ignores: ['dist', '**/*.js']
12+
files: ['**/*.ts']
1113
},
1214
// Stylistic
1315
{
@@ -39,9 +41,16 @@ export default [
3941
// Custom
4042
{
4143
rules: {
42-
'@typescript-eslint/no-magic-numbers': 'off',
43-
'jest/consistent-test-it': ['error', { fn: 'test' }]
44+
'jest/consistent-test-it': ['error', { fn: 'test' }],
45+
'max-nested-callbacks': 'off',
46+
'max-lines': 'off'
4447
},
4548
files: ['tests/**.test.ts']
49+
},
50+
{
51+
files: ['**/*.ts'],
52+
rules: {
53+
'@typescript-eslint/no-magic-numbers': 'off'
54+
}
4655
}
47-
]
56+
])

0 commit comments

Comments
 (0)