New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

normik

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

normik

Fast and simple library for convert your data from server to store and backward.

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

normik

Fast and simple library for convert your data from server to store and backward.

Version Build Status Tweet

Installation

npm install normik --save

If you find bag, please create ISSUE.

Scheme structure

[
    [field_name_server, field_name_client?, default_value?],
    [field_name_server, field_name_client?, default_value?],
    /// other fields
]

If not field_name_client will be set default field_name_server.

If you need set default value, but don't need set field_name_client, plese set

field_name_client = "";

If you need usage nesting, please use dot in field name

money.now

{
    ...other data
    money: {
        now: $value$
    }
}

Example usage

Example scheme convert

const scheme = [
  ["user_name", "userName"],
  ["age"],
  ["money.now", "moneyNow", 0],
  ["email", "", null],
  ["phones", "phone.bob"]
];

Example data from server

const data = {
  "user_name": "bob",
  "age": 7,
  "money": {
    "now": 10
  },
  "phones": [7914, 8914]
}

Convert from server

import { norm2Store } from "normik";

const res = norm2Store(data, scheme);

Result

{
  "userName": "bob",
  "age": 7,
  "moneyNow": 10,
  "email": null,
  "phone": {
    "bob": [7914, 8914]
  }
}

Convert result to server

import { norm2Server } from "normik";

const res = norm2Server(data, scheme);

Result

{
  "user_name": "bob",
  "age": 7,
  "money": {
    "now": 10
  },
  "email": null,
  "phones": [7914, 8914]
}

Licence MIT.

FAQs

Package last updated on 10 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts