@vill-v/path-prop
v1.3.3
Published
一个基于路径字符串对对象进行操作的工具
Downloads
242
Readme
@vill-v/path-prop
neta了崩坏3 往世乐土的英杰维尔薇
一个基于路径字符串对对象进行操作的工具
安装
# ✨ Auto-detect
npx nypm install @vill-v/path-prop
# npm
npm install @vill-v/path-prop
# yarn
yarn add @vill-v/path-prop
# pnpm
pnpm install @vill-v/path-prop
# bun
bun install @vill-v/path-prop
# deno
deno install @vill-v/path-prop
说明
只是个人项目,整体较为随便,作为开发途中的经验总结,如有相似的需求,推荐copy或阅读源码,不建议将该包在实际项目中使用
如有幸被实际使用在项目内,不胜荣幸
const obj = {test: [{test1: 'test2'}]}
getByPath(obj, 'test[0].test1')
// -> test2
const obj1 = {test: [{test1: 'test2'}]}
setByPath(obj1, 'test[0].test1', 'test3')
// obj -> {test: [{test1: 'test3'}]}
const obj2 = {test: [{test1: 'test2'}]}
delByPath(obj2, 'test[0]')
// obj -> {test: []}
const obj3 = {test: [{test1: 'test2'}]}
hasByPath(obj3, 'test[0].test1')
// -> true
Published under the MIT license. Made by @Colourlessglow and community 💛
🤖 auto updated with automd