# nullcake

> null is not scary

Latest version **1.0.2** (published 2022-09-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install nullcake
pnpm add nullcake
yarn add nullcake
bun add nullcake
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-09-01 |
| First published | 2022-09-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | chengy |
| Keywords | null, Null, NULL |

## Links

- npm: https://www.npmjs.com/package/nullcake
- npm.io page: https://npm.io/package/nullcake

## Dependencies (1)

- [babel](https://npm.io/package/babel.md) ^6.23.0

## Recent versions

- 1.0.2 (latest) — 2022-09-01

## README

## nullCake

1. check if the data is null or undefined

### example

```javascript
import nullCake from "nullCake";

const myDataCheck = nullCake();
//getType
const myDataType = myDataCheck.getType(data);
//check data
const isNull = myDataCheck.check(data);
// translate data to targetType
const myDataNew = myDataCheck.setData(datatypeObj, dataObj);
```

### methods

| Method  | Description                                    |
| ------- | ---------------------------------------------- |
| getType | get data type ,return data's type in lowerCase |
| check   | check if the data is null or undefined         |
| setData | translate data to targetType                   |

#### use methods

1. getType

   - get data type ,return data's type in lowerCase

```javascript
const data = "get my data type";
const type = nullCake.getType(data);
console.log({ type }); // type: 'string'
```

2. check

   - check if the data is null or undefined

```javascript
  const data = null
  const isNull = nullCake.check(data)
  console.log({isNull}) // isNull: true
  --------------------------------------------------------
  const dataString = 'null' | 'Null' |'NULL'
  const isNull = nullCake.check(dataString)
  console.log({isNull}) // isNull: 'null string'
  --------------------------------------------------------
  const dataUndefined = undefined
  const isNull = nullCake.check(dataUndefined)
  console.log({isNull}) // isNull: 'undefined'
  --------------------------------------------------------
  const undefinedStr = 'undefined' | 'Undefined' |'UNDEFINED'
  const isNull = nullCake.check(undefinedStr)
  console.log({isNull}) // isNull: 'undefined string'
  --------------------------------------------------------
  const data = 'string' | [] | ...
  const isNull = nullCake.check(data)
  console.log({isNull}) // isNull: false
```

3. setData
   - translate data to targetType

```javascript
const targetData = { a: "", b: [], c: 0, d: () => {} };
const orginData = { a: "had a value", b: null, d: undefined };
const tData = nullCake.setData(targetData, orginData);
console.log({ tData }); // tData: {a: 'had a value', b:[], c:0, d:()=>{}}
```

---
_Source: https://npm.io/package/nullcake · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
