Skip to content

Commit

Permalink
chore(release): 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
oritwoen committed Jan 4, 2023
0 parents commit d5aeb37
Show file tree
Hide file tree
Showing 11 changed files with 3,778 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
]
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
coverage
node_modules
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### 1.0.0 (2023-01-04)
- Initial release
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 - Dominik Opyd (Oritwoen)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
104 changes: 104 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<h1 align='center'>nordi</h1>

<p align="center">
<a href="https://www.npmjs.com/package/nordi" target="_blank"><img src="https://img.shields.io/npm/v/nordi?style=flat&colorA=130f40&colorB=474787" alt="npm version"></a>
<a href="https://www.npmjs.com/package/nordi" target="_blank"><img src="https://img.shields.io/bundlephobia/min/nordi?style=flat&colorA=130f40&colorB=474787" alt="npm size"></a>
<a href="https://www.npmjs.com/package/nordi" target="_blank"><img src="https://img.shields.io/npm/dm/nordi?flat&colorA=130f40&colorB=474787" alt="npm downloads"></a>
<a href="https://github.com/oritwoen/nordi" target="_blank"><img src="https://img.shields.io/github/stars/oritwoen/nordi?flat&colorA=130f40&colorB=474787" lt="github stars"></a>
</p>

<p align="center">
Normalize data with interfaces.
</p>

## Why?

In many projects where it is necessary to use different APIs for the same purpose, there is a huge problem with standardization.

It is always a waste of time and almost always writing new functions and data normalization separately for each project.

What if there was a simple function that normalizes data according to a predetermined pattern? – it was on the basis of this thought that `nordi` was created.


## Install

```bash
npm install --save nordi

# Using pnpm
pnpm add nordi

# Using yarn
yarn add nordi
```


## Usage

### 1. Define Interface

To normalize data, you need to create an interface/schema beforehand.

The principle of operation is very simple. `catch` grabs the appropriate variable from the object and `transform` converts it to the selected format.

```ts
const blockInterface = {
hash: {
catch: ['hash', 'blockhash'],
transform: (value: any) => String(value)
},

number: {
catch: ['height', 'number', 'blockHeight'],
transform: (value: any) => Number(value)
},
}
```

### 2. Prepare a dataset

Of course, different data sets are required to normalize different data.

For example, I used blocks of various cryptocurrencies here.

```ts
const solanaBlock = {
"blockhash": "4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZAMdL4VZHirAn",
"blockHeight": 0
}

const bitcoinBlock = {
"hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
"height": 0
}

const ethereumBlock = {
"hash": "0x0000000000000000000000000000000000000000",
"number": 0,
}
```

### 3. Normalization

Of course, different data sets are required to normalize different data.

For example, I used blocks of various cryptocurrencies here.

```ts
const { useNormalizedData } from 'nordi'

const normalizedSolanaBlock = useNormalizedData(blockInterface, solanaBlock)
const normalizedBitcoinBlock = useNormalizedData(blockInterface, bitcoinBlock)
const normalizedEthereumBlock = useNormalizedData(blockInterface, ethereumBlock)

console.log(normalizedSolanaBlock)

//{
// hash: "4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZAMdL4VZHirAn"
// number: 0
//}
```

## License

MIT License © 2023 [Dominik Opyd](https://github.com/oritwoen)
39 changes: 39 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "nordi",
"version": "1.0.0",
"description": "Normalize data with interfaces.",
"repository": "oritwoen/nordi",
"license": "MIT",
"sideEffects": false,
"type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"dev": "vitest dev",
"lint": "eslint --ext .ts,.js,.mjs,.cjs .",
"test": "pnpm lint && vitest run --coverage",
"build": "unbuild",
"prepack": "unbuild",
"release": "pnpm test && standard-version && git push --follow-tags && pnpm publish"
},
"devDependencies": {
"vitest": "0.26.3",
"eslint": "8.31.0",
"unbuild": "1.0.2",
"typescript": "4.9.4",
"standard-version": "9.5.0",
"@vitest/coverage-c8": "0.26.3"
},
"packageManager": "pnpm@7.22.0"
}
Loading

0 comments on commit d5aeb37

Please sign in to comment.