Skip to content

Commit

Permalink
Merge pull request #129 from ndaidong/11.1.0
Browse files Browse the repository at this point in the history
v11.1.0
  • Loading branch information
ndaidong committed Oct 12, 2022
2 parents 80d8f2c + f7242c0 commit 60eebba
Show file tree
Hide file tree
Showing 16 changed files with 196 additions and 111 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node_version: [14.x, 15.x, 16.x, 17.x, 18.x]
node_version: [15.x, 16.x, 17.x, 18.x]

steps:
- uses: actions/checkout@v2
Expand Down
58 changes: 38 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ You may be interested in [BellaPy](https://github.com/ndaidong/bellapy) too.
* [Array utils](#array-utils): [`pick`](#pickarray-arr--number-count--1), [`sort`](#sortarray-arr--function-compare), [`sortBy`](#sortbyarray-arr-number-order-string-property), [`shuffle`](#shufflearray-arr), [`unique`](#uniquearray-arr)
* [Functional utils](#functional-utils): [`curry`](#curryfn), [`compose`](#composef1-f2-fn), [`pipe`](#pipef1-f2-fn), [`maybe`](#maybeanything-val)
* [Date utils](#date-utils): [`formatDateString`](#formatdatestringdate--timestamp--string-locale--object-options), [`formatTimeAgo`](#formattimeagodate--timestamp--string-locale--string-justnow)
* [Other utils](#other-utils): [`randint`](#randintnumber-min--number-max), [`genid`](#genidnumber-length--string-prefix)
* [Crypto utils](#crypto-utils): [`sha256`](#sha256), [`sha512`](#sha512)
* [Random utils](#random-utils): [`randint`](#randintnumber-min--number-max), [`genid`](#genidnumber-length--string-prefix)

* [Test](#test)

* [License](#license)

## Install
## Install & Usage

- Node.js
### Node.js

```bash
npm i bellajs
Expand All @@ -41,29 +42,22 @@ pnpm i bellajs
yarn add bellajs
```

- Browser
### Deno

```html
<script type="module">
import { genid } from 'https://unpkg.com/bellajs/dist/bella.esm.js'
```ts
import { genid } from 'https://esm.sh/bellajs'

console.log(genid())
</script>
```

### Browser

## Usage
```html
<script type="module">
import { genid, slugify } from 'https://unpkg.com/bellajs/dist/bella.esm.js'
```js
import {
genid,
slugify
} from 'bella'

const postId = genid(32)
console.log(postId)
const slug = slugify('Goldman Sachs, JPMorgan Predict Euro-Area Recession')
console.log(slug)
console.log(genid())
</script>
```

## APIs
Expand Down Expand Up @@ -495,7 +489,29 @@ Please refer the following resources for more info:
- [Intl.Locale](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale)


### Other utils
### Crypto utils

#### `sha256()`

Generate signature for a text using SHA-256 Cryptographic Hash Algorithm.

```js
import { sha256 } from 'bellajs'

sha256(text) // => hashed string 64 hex characters, 256-bit (16-byte)
```

#### `sha512()`

Generate signature for a text using SHA-512 Cryptographic Hash Algorithm.

```js
import { sha512 } from 'bellajs'

sha512(text) // => hashed string 128 hex characters, 512-bit (32-byte)
```

### Random utils

#### `randint([Number min [, Number max]])`

Expand All @@ -521,6 +537,8 @@ genid(5) // => random 5 chars
genid(5, 'X_') // => X_{random 3 chars}
```

When `length` > 128, only first 99 characters are being generated using `crypto.getRandomValues()`, the rest will be calculated with `Math.random()`.

## Test

```bash
Expand Down
4 changes: 2 additions & 2 deletions dist/bella.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 60eebba

Please sign in to comment.