@boruei.chen/utils
v1.7.0
Published
Utility functions
Downloads
12
Readme
Utils
Utility functions.
Installation
Utils is available as an npm package.
npm
npm install @boruei.chen/utils
yarn
yarn add @boruei.chen/utils
Usage
- replaceNullWithEmptyStringDeep
- replaceEmptyStringWithNullDeep
- getObjectKeyByValue
- getEnAlphabetList
- convertToROCDate
- convertToADDate
replaceNullWithEmptyStringDeep
import { replaceNullWithEmptyStringDeep } from '@boruei.chen/utils';
const mockData = {
keyA: null,
keyB: [
{
keyB1: null,
keyB2: null,
keyB3: null
},
{
keyB1: null,
keyB2: null,
keyB3: null
},
{
keyB1: null,
keyB2: null,
keyB3: null
}
],
keyC: null
};
replaceNullWithEmptyStringDeep(mockData);
// Result:
// {
// keyA: '',
// keyB: [
// {
// keyB1: '',
// keyB2: '',
// keyB3: ''
// },
// {
// keyB1: '',
// keyB2: '',
// keyB3: ''
// },
// {
// keyB1: '',
// keyB2: '',
// keyB3: ''
// }
// ],
// keyC: ''
// }
replaceEmptyStringWithNullDeep
import { replaceEmptyStringWithNullDeep } from '@boruei.chen/utils';
const mockData = {
keyA: '',
keyB: [
{
keyB1: '',
keyB2: '',
keyB3: ''
},
{
keyB1: '',
keyB2: '',
keyB3: ''
},
{
keyB1: '',
keyB2: '',
keyB3: ''
}
],
keyC: ''
};
replaceEmptyStringWithNullDeep(mockData);
// Result:
// {
// keyA: null,
// keyB: [
// {
// keyB1: null,
// keyB2: null,
// keyB3: null
// },
// {
// keyB1: null,
// keyB2: null,
// keyB3: null
// },
// {
// keyB1: null,
// keyB2: null,
// keyB3: null
// }
// ],
// keyC: null
// }
getObjectKeyByValue
import { getObjectKeyByValue } from '@boruei.chen/utils';
const mockObject = {
keyA: 'a',
keyB: 'b',
keyC: 'c'
};
const mockValue = 'b';
getObjectKeyByValue(mockObject, mockValue);
// Result:
// keyB
getEnAlphabetList
import { getEnAlphabetList } from '@boruei.chen/utils';
getEnAlphabetList();
// Result:
// ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
convertToROCDate
import { convertToROCDate } from '@boruei.chen/utils';
const mockDate = '2023/05/22';
convertToROCDate(mockDate);
// Result:
// '112/05/22'
convertToADDate
import { convertToADDate } from '@boruei.chen/utils';
const mockDate = '112/05/22';
convertToADDate(mockDate);
// Result:
// '2023/05/22'
Technologies
License
This project is licensed under the terms of the MIT license.