0.0.24 • Published 1 year ago

@datage/rest-api v0.0.24

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@datage/rest-api

Usage

toSnakeCase

import { toSnakeCase } from '@datage/rest-api'
const snaked = toSnakeCase('camelCase')
snaked === 'camel_case'

toCamelCase

import { toSnakeCase } from '@datage/rest-api'
const camel = toCamelCase('snake_case')
camel === 'snakeCase'

isObject

import { isObject } from '@datage/rest-api'
isObject(null)       // false
isObject(undefined)  // false
isObject(1)          // false
isObject('test')     // false
isObject(new Date()) // false
isObject([1])        // false
isObject({ a: 1 }})  // true

mapObjectKeys

import { mapObjectKeys, toSnakeCase } from '@datage/rest-api'
const camelObj = objectKeysToCamelCase({ snake_case: { more_snake_: [{ my_snake_: 1 }]}}, toSnakeCase)
console.log(camelObj) // { snakeCase: { moreSnake_: [{ mySnake_: 1 }]}}

objectKeysToCamelCase

import { objectKeysToCamelCase } from '@datage/rest-api'
const camelObj = objectKeysToCamelCase({ snake_case: { more_snake_: [{ my_snake_: 1 }]}})
console.log(camelObj) // { snakeCase: { moreSnake_: [{ mySnake_: 1 }]}}

objectKeysToSnakeCase

import { objectKeysToSnakeCase } from '@datage/rest-api'
const snakeObj = objectKeysToSnakeCase({ camelCase: { moreCamel: [{ myCamel: 1 }]}})
console.log(snakeObj) // { camel_case: { more_camel: [{ my_camel: 1 }]}}

getIn

import { getIn } from '@datage/rest-api'
const obj = { a: { b: { c: 1 } } }
const c = getIn(obj, 'a.b.c')
console.log(c) // 1

setIn

import { setIn } from '@datage/rest-api'
const obj = { a: { b: { c: 1 } } }
const obj1 = setIn(obj, 'a.b.d', 2)
console.log(obj1) // { a: { b: { c: 1, d: 2 } } }
0.0.20

1 year ago

0.0.21

1 year ago

0.0.22

1 year ago

0.0.23

1 year ago

0.0.24

1 year ago

0.0.19

1 year ago

0.0.18

3 years ago

0.0.13

3 years ago

0.0.14

3 years ago

0.0.16

3 years ago

0.0.17

3 years ago

0.0.12

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago