@abetomo/mask-value 中文文档教程
node-mask-value
屏蔽对象的值。
Install
% npm i @abetomo/mask-value
Examples
import { mask, masks, Config } from '@abetomo/mask-value'
type User = {
name: string
address: string
}
const data: User[] = [
{
name: 'name1',
address: 'address1'
},
{
name: 'name2',
address: 'address2'
}
]
const config: Config = {
path: '.[].name',
action: () => Math.random()
}
console.log(mask<User[]>(data, config))
/*
Output:
[
{ name: 0.913236932864554, address: 'address1' },
{ name: 0.6970620876451457, address: 'address2' }
]
*/
const configs: Config[] = [
{
path: '.[].name',
action: () => Math.random()
},
{
path: '.[].address',
action: (s: string) => s.length * Math.random()
}
]
console.log(masks<User[]>(data, configs))
/*
Output:
[
{ name: 0.4253394097546368, address: 4.285149904757429 },
{ name: 0.7394228798993354, address: 6.334446902953465 }
]
*/
node-mask-value
Mask the value of the object.
Install
% npm i @abetomo/mask-value
Examples
import { mask, masks, Config } from '@abetomo/mask-value'
type User = {
name: string
address: string
}
const data: User[] = [
{
name: 'name1',
address: 'address1'
},
{
name: 'name2',
address: 'address2'
}
]
const config: Config = {
path: '.[].name',
action: () => Math.random()
}
console.log(mask<User[]>(data, config))
/*
Output:
[
{ name: 0.913236932864554, address: 'address1' },
{ name: 0.6970620876451457, address: 'address2' }
]
*/
const configs: Config[] = [
{
path: '.[].name',
action: () => Math.random()
},
{
path: '.[].address',
action: (s: string) => s.length * Math.random()
}
]
console.log(masks<User[]>(data, configs))
/*
Output:
[
{ name: 0.4253394097546368, address: 4.285149904757429 },
{ name: 0.7394228798993354, address: 6.334446902953465 }
]
*/
更多
你可能也喜欢
- 1clickcrawl 中文文档教程
- 4square-venues 中文文档教程
- @12luckydev/array-handler 中文文档教程
- @18f/eslint-plugin-identity 中文文档教程
- @2600hz/commio-native-utilities 中文文档教程
- @7inch/create-7inch-app 中文文档教程
- @a.abunada/expo-location 中文文档教程
- @aaronellington/npm-style-config 中文文档教程
- @aarongray.org/xlsx-workbook 中文文档教程
- @abakermi/towords 中文文档教程