{"_id":"@aimjs/vuex-helper","_rev":"1-71236adf61ef656d983c209877502f50","name":"@aimjs/vuex-helper","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@aimjs/vuex-helper","version":"0.0.1","main":"dist/index.cjs.js","module":"dist/index.esm.js","browser":"dist/index.umd.js","description":"A tiny utility to generate vuex state and mutations easily","keywords":["vuex","helper"],"scripts":{"test":"jest","build":"rollup -c","dev":"rollup -c -w","pretest":"yarn build"},"homepage":"https://github.com/Youzhigang/vuex-helper.git#readme","bugs":{"url":"https://github.com/Youzhigang/vuex-helper/issues"},"devDependencies":{"@rollup/plugin-buble":"^0.21.1","@rollup/plugin-commonjs":"^11.0.2","@rollup/plugin-node-resolve":"^7.1.1","jest":"^25.1.0","rollup":"^2.0.2"},"repository":{"type":"git","url":"git+https://github.com/Youzhigang/vuex-helper.git"},"author":{"name":"ethany"},"license":"MIT","peerDependencies":{"vue":"^2.0.0"},"gitHead":"cfb2bd186c57579bd6d0c17fdb8079e5804c99a0","_id":"@aimjs/vuex-helper@0.0.1","_nodeVersion":"12.14.0","_npmVersion":"6.13.4","dist":{"integrity":"sha512-oSIA0fBHvUtGU1D8hitKD3f8/+qKUB4fCrBPdusOroHelM2Cr8NWr14qfOvsHKU/dCNXO8rS3MZGUJNOmAD8pQ==","shasum":"8c32a65a51104c5025d843c04bccf46cf755a580","tarball":"https://registry.npmjs.org/@aimjs/vuex-helper/-/vuex-helper-0.0.1.tgz","fileCount":6,"unpackedSize":8175,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeZQylCRA9TVsSAnZWagAA8oYP/i4+p48vovsI5s5rD4wQ\nxiY3X/f/6j5fApwXL2AqRBQm0cIUPH5gVq0CiYfVbNu4rMMF7mzoWTkwX9Zs\nvBJo5LAY2hnqE6XaMUweSEl2eL76RcRXWgkIuWCYlJi5L49+5J9ll0Megckj\nqkOVXBgEQRwwXJSBS10ZmNescdZPJmrWC/v/l0R8PKiqjrXiQ3HtFFUQhqtb\nOh3Zt7kuQU6KToVuXTqkOdFk0IXX5Iv0/8p2SNzetkJdztXcXdr2/XPecPPG\na6xODPhXKrerLxkrb09VSFPDWLyNZu1hp7bGmwA6rsXf0HSaqF2lzS5qAeb2\nE09bZXpbkV8p7ajh7jN0eVC7xkLMbTL/ddvQQx441m+PoGwaz/3rADF3BW99\n4Juy5nF+wZP6j9/dI7Nh24W4pbsnCc0DkQu/lxtFZKl/TNNM+hljGC2o5GsP\nEj3UOUWT21C2sZpQ3qKcuUokbFaMwxZF9bAzpnFlWyDrtfETa2gguGAJQfAf\nj4PWMaz8jVHi4PgscTgkADKsk9/5WrrQaQHdqAJxHX808UpvsEM7O7CpKnUo\nAw+oC9bmKtvcck+DQv+Jg9DDobkz895UYkOlZ3c0yDHrA7xLYiVG7kxDM1jv\nH/ADk7bBRJPlIi7YcJtbC7slVZSxNWx/xGNCFiOLPROBMny+fdmNBczGsvXc\nAyhP\r\n=Nqet\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDcrJUnMDa/nQGd5ftV1oJBfZjmha4Ps5akeY+E8L1OkQIgWIKYJrqhGeiv//M3+jsOs1jP6/OuI+u10RtvVAFQs+c="}]},"maintainers":[{"name":"ethany","email":"651992456@qq.com"}],"_npmUser":{"name":"ethany","email":"651992456@qq.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vuex-helper_0.0.1_1583680677293_0.3741427593236448"},"_hasShrinkwrap":false}},"time":{"created":"2020-03-08T15:17:57.063Z","0.0.1":"2020-03-08T15:17:57.447Z","modified":"2022-04-04T12:19:23.988Z"},"maintainers":[{"name":"ethany","email":"651992456@qq.com"}],"description":"A tiny utility to generate vuex state and mutations easily","homepage":"https://github.com/Youzhigang/vuex-helper.git#readme","keywords":["vuex","helper"],"repository":{"type":"git","url":"git+https://github.com/Youzhigang/vuex-helper.git"},"author":{"name":"ethany"},"bugs":{"url":"https://github.com/Youzhigang/vuex-helper/issues"},"license":"MIT","readme":"# vuex-helper\n\n通过声明JSON schema 对象(语法和vue组件props类似)的形式生成对应的 vuex state 和 mutations\n\n## example\n\n```javascript\nimport  { createState, createMutations } from '@sh/vuex-helper'\n\nconst testSchema = {\n  properties: {\n    num: {\n      type: Number\n    },\n    str: {\n      type: String\n    },\n    bool: {\n      type: Boolean\n    },\n    arr: {\n      type: Array\n    },\n    obj: {\n      type: Object\n    }\n  }\n}\n\nconst state = createState(testSchema)\nconsole.log(state)\n/*\n  {\n    num: 0,\n    str: \"\",\n    bool: false,\n    arr: [],\n    obj: {}\n  }\n*/\n\nconst mutations = createMutations(testSchema)\nconsole.log(mutations)\n/*\n  {\n    setNum: (state, newVal) => {\n      state.num = newVal\n    },\n    setStr: (state, newVal) => {\n      state.str = newVal\n    },\n    setBool: (state, newVal) => {\n      state.bool = newVal\n    },\n    setArr: (state, newVal) => {\n      state[\"arr\"] = newVal\n    },\n    setObj: (state, newVal) => {\n      state[\"obj\"] = newVal\n    }\n  }\n*/\n\n/**\n * new Vuex.Store ({\n *  state,\n *  mutations\n * })\n */\n```\n\n支持嵌套的state, 但是不支持嵌套的mutation\n\n```javascript\nconst nested = {\n  properties: {\n    obj: {\n      type: Object,\n      properties: {\n        obj1: {\n          type: Object,\n        }\n      }\n    }\n  }\n}\nconst state = createState(nested) // { obj: { obj1: { a: 1, b: 666 } } }\nconst mutations = createMutations(nested) // { setObj: [Function] }\n```\n\n## License\n\n[MIT](LICENSE).\n","readmeFilename":"README.md"}