0.0.0-4 • Published 5 years ago

seal-helper v0.0.0-4

Weekly downloads
4
License
MIT
Repository
gitlab
Last release
5 years ago

seal-helper

Tired of writing repetitive code? Dun worry seal-helper will help you

how to use

  1. yarn add seal-helper
  2. import where you need it
import {
    request,
    cookie,
    replaceInput,
} from 'seal-helper'
  1. make request
const cbSuccess = res => {}
const cbError = err => {}

request({
    req: {
        type: 'POST',
        headers: {...},
        data: {},
        qs: {},
        routes: '/v1/user',
        endpoint: 'https://abc.com',
    },
    successCriteria: {
        header: 200,
        hasData: true,
        hasColumn: 'id',
        typeofData: 'array',
    },
    onSuccess: (res) => cbSuccess(res),
    onError: (err) => cbError(err),
})
  1. cookie method (get, getAll, set, remove)

get

const userCookie = cookie.get({ name: 'user' })

getAll

const allCookies = cookie.getAll()

remove cookie

cookie.remove({ name: 'user' })

set cookie options (object): Support all the cookie options from RFC 6265 path (string): cookie path, use / as the path if you want your cookie to be accessible on all pages expires (Date): absolute expiration date for the cookie maxAge (number): relative max age of the cookie from when the client receives it in second domain (string): domain for the cookie (sub.domain.com or .allsubdomains.com) secure (boolean): Is only accessible through HTTPS? httpOnly (boolean): Is only the server can access the cookie? sameSite (boolean|lax|strict): Strict or Lax enforcement

cookie.set({ name, value, options })
  1. replace input
const newInput = replaceInput({
    value: '',
    regex: 'url', // regex name: url, number, string, autonumeric,
    replacer: 'x', // value that didnt match regex will be replaced by x
})

input

replaceInput({
  "value": "H3LL0",
  "regex": "alpha",
  "replacer": ""
})

replaceInput({
  "value": "hello",
  "regex": "numeric",
  "replacer": "0"
})

output

HLL
00000
0.0.0-4

5 years ago

0.0.0-3

5 years ago

0.0.0-2

5 years ago

0.0.0-1

5 years ago

0.0.0

5 years ago