{"_id":"@alfdocimo/rondel","_rev":"1-645c1a9f439d686cf1773c5c14dc655e","name":"@alfdocimo/rondel","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.5":{"name":"@alfdocimo/rondel","version":"1.0.5","description":"Javascript library that makes use of the Proxy API to control objects through the use of handlers.","main":"build/index.js","scripts":{"build":"webpack","format":"prettier --write **/*.{js,jsx,css,md}","test":"cross-env NODE_ENV=dev jest","test:prod":"cross-env NODE_ENV=prod jest --coverage","test:watch":"cross-env NODE_ENV=dev jest --watchAll","prepare":"yarn build"},"repository":{"type":"git","url":"git+https://github.com/alfdocimo/rondel.git"},"author":{"name":"Alfredo Narvaez Docimo","email":"alfredonado@gmail.com","url":"https://github.com/alfdocimo"},"license":"MIT","bugs":{"url":"https://github.com/alfdocimo/rondel/issues"},"homepage":"https://github.com/alfdocimo/rondel","keywords":["library","starter","es6"],"devDependencies":{"@babel/cli":"^7.4.4","@babel/core":"^7.4.5","@babel/plugin-proposal-class-properties":"^7.4.4","@babel/plugin-transform-runtime":"^7.4.4","@babel/polyfill":"^7.4.4","@babel/preset-env":"^7.4.5","@babel/runtime":"^7.4.5","babel-loader":"^8.0.6","babel-preset-minify":"^0.5.0","camelcase":"^5.3.1","cross-env":"^5.2.0","css-loader":"^3.0.0","file-loader":"^4.0.0","jest":"^24.8.0","jest-sonar-reporter":"^2.0.0","prettier":"^1.18.2","prettier-webpack-plugin":"^1.2.0","style-loader":"^0.23.1","url-loader":"^2.0.0","webpack":"^4.34.0","webpack-cli":"^3.3.4"},"dependencies":{},"jest":{"moduleNameMapper":{"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":"<rootDir>/scripts/testMock.js","\\.(css|less)$":"<rootDir>/scripts/testMock.js"},"testResultsProcessor":"jest-sonar-reporter","collectCoverageFrom":["src/*.js"],"coveragePathIgnorePatterns":["/node_modules/"],"coverageThreshold":{"global":{"statements":65,"branches":65,"functions":65,"lines":65}}},"jestSonar":{"env":{"prod":{"reportPath":"./reports/prod","reportFile":"test-reporter.xml","indent":4},"dev":{"reportPath":"./reports/dev","reportFile":"test-reporter.xml","indent":4}}},"gitHead":"b94b0fa562f5f3a2abcdef3e09a273242b5ece80","_id":"@alfdocimo/rondel@1.0.5","_npmVersion":"6.4.1","_nodeVersion":"8.16.0","_npmUser":{"name":"alfdocimo","email":"alfredonado@gmail.com"},"dist":{"integrity":"sha512-SXpPSTbNmj8LUVjsHnVVdGL0NDo4BOskqg6FCvUBj0qFJeAVzdfDUXLLGGNpRnj5O340mbPtI1su8c7u9uhymQ==","shasum":"ef4fa81ceb60fd9df7fa07989abeaccf8747759d","tarball":"https://registry.npmjs.org/@alfdocimo/rondel/-/rondel-1.0.5.tgz","fileCount":13,"unpackedSize":285070,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdFhhvCRA9TVsSAnZWagAAcvoP/2biygWomKRlTQk6aTu1\nENVr/qu2/7LKKU3OKm3hlpSzRFP5AVoOMumjYxwC4q+GDCB3OGokc6786sE1\nVtOkbnf5TbW0s7zIx5R5z6OkKREHQmdvrqzJJz6CYghdNlbK2ogyBQ5P2esl\neqDvl+PRUoI3RyxbqmIz4rvADOCBp0T2uA4jv4CmJ8JZczIKZBlKfGhTs5pK\nDKIDcTkgYraA1wz0xj9Ss00gpKOtNbhNoQUUVlJOqSRHEFP6LPZo3VuZpmGn\ntN4bmxZ+cHY+FONpcawrvAV20UA2HggvssmGQmLyxCPwrJ9tQDiJLJ9jqNs7\nWTgl5+CUkzlOwOwJhT2PZrAM3kBvwF9jsGboGLb5B98n5m6c13PQapLKXcP+\ns6xJtRYHqCwE0LSMY/LPq6o8uus+DJcCNKKMA6hgHfWdGROcz/RUj/mUJibG\nMTLy7QLPmjV/gDZfxavRPZLPKL9aCp4VT07imbYrSxqcThXLRxzWs+UDCVyk\nR/ep+I4U//6XbeepypJOGxfHRNgl2QxHEWQSmWx0GUT9fjfVmw0VbRX6eSMt\nc9vIucPSLkWt72jvmfEmQLC7V+YdsoImOB4tummNTe4GU/thWcxuBtpb64iV\n8lHBVK+RmV3+SxF79iB2Nr2jMM8wRVBraf4TU+jU8AlJYdS5yzPvxhNJH9Wl\nxGcy\r\n=kvIs\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIE2uxXPkYdT6U8+j2Z3cYR6WmhyVj1tsAjrKA0PNdgzUAiEA56NGzVfH86nseoIIRWHHb+tHmtJfnz0RVoKVnggbjMc="}]},"maintainers":[{"name":"alfdocimo","email":"alfredonado@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rondel_1.0.5_1561729134349_0.09539090784427406"},"_hasShrinkwrap":false}},"time":{"created":"2019-06-28T13:38:54.321Z","1.0.5":"2019-06-28T13:38:54.464Z","modified":"2022-04-04T12:49:01.813Z"},"maintainers":[{"name":"alfdocimo","email":"alfredonado@gmail.com"}],"description":"Javascript library that makes use of the Proxy API to control objects through the use of handlers.","homepage":"https://github.com/alfdocimo/rondel","keywords":["library","starter","es6"],"repository":{"type":"git","url":"git+https://github.com/alfdocimo/rondel.git"},"author":{"name":"Alfredo Narvaez Docimo","email":"alfredonado@gmail.com","url":"https://github.com/alfdocimo"},"bugs":{"url":"https://github.com/alfdocimo/rondel/issues"},"license":"MIT","readme":"_Created by: Alfredo Narváez, 2019_\r\n\r\n# 🛡️ Rondel\r\n\r\n⚙️ **Travis CI** 🛠️\r\n\r\n[![Build Status](https://travis-ci.com/alfdocimo/rondel.svg?branch=master)](https://travis-ci.com/alfdocimo/rondel)\r\n\r\n👩‍🔬 **SonarQube** 👨‍🔬\r\n\r\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=alfdocimo_rondel&metric=alert_status)](https://sonarcloud.io/dashboard?id=alfdocimo_rondel)\r\n[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=alfdocimo_rondel&metric=bugs)](https://sonarcloud.io/dashboard?id=alfdocimo_rondel)\r\n[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=alfdocimo_rondel&metric=code_smells)](https://sonarcloud.io/dashboard?id=alfdocimo_rondel)\r\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=alfdocimo_rondel&metric=coverage)](https://sonarcloud.io/dashboard?id=alfdocimo_rondel)\r\n[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=alfdocimo_rondel&metric=ncloc)](https://sonarcloud.io/dashboard?id=alfdocimo_rondel)\r\n[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=alfdocimo_rondel&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=alfdocimo_rondel)\r\n[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=alfdocimo_rondel&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=alfdocimo_rondel)\r\n[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=alfdocimo_rondel&metric=security_rating)](https://sonarcloud.io/dashboard?id=alfdocimo_rondel)\r\n[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=alfdocimo_rondel&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=alfdocimo_rondel)\r\n[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=alfdocimo_rondel&metric=sqale_index)](https://sonarcloud.io/dashboard?id=alfdocimo_rondel)\r\n\r\nRondel is a library that makes use of the JavaScript Proxy API and exposes certain functionalities to protect & control objects through the use of handlers.\r\n\r\n**Why \"Rondel\"?**\r\n\r\n_A rondel (ˈrɒndl) is a circular piece of metal used for protection in suits of armor_\r\n\r\n![rondeljs](https://i.imgur.com/St4R0OL.png)\r\n\r\n# Installing\r\n\r\nFirst things first! You gotta install `rondel` as a dependency, so go ahead and run:\r\n\r\n```\r\nyarn add -D rondel\r\n```\r\n\r\nor if you're using npm:\r\n\r\n```\r\nnpm install --save-dev rondel\r\n```\r\n\r\nOkay! Once that's done, you're ready to go!\r\n\r\n# Protecting Objects:\r\n\r\nLet's say you want to create a protected `Object`\r\n\r\n```js\r\nimport Rondel from 'rondel';\r\n\r\nconst rondel = new Rondel();\r\n\r\nconst myObj = rondel.createProtected({\r\n  obj: { name: 'John', lastName: 'Doe' },\r\n  modifiers: {},\r\n});\r\n\r\nconsole.log(myObj.randomProp); // unset property\r\n```\r\n\r\nHow about controlling the undefined props of our objects?\r\n\r\n```js\r\nimport Rondel from 'rondel';\r\n\r\nconst rondel = new Rondel();\r\n\r\nconst myObj = rondel.createProtected({\r\n  obj: { name: 'John', lastName: 'Doe' },\r\n  modifiers: { exposeDefault: [] },\r\n});\r\n\r\nconsole.log(myObj.randomProp); // []\r\n```\r\n\r\nAlright... how about restricting setting properties?\r\n\r\n```js\r\nimport Rondel from 'rondel';\r\n\r\nconst rondel = new Rondel();\r\n\r\nconst myObj = rondel.createProtected({\r\n  obj: { name: 'John', lastName: 'Doe' },\r\n  modifiers: { exposeDefault: [], setNotAllowed: true },\r\n});\r\n\r\nconsole.log(myObj.randomProp); // []\r\n\r\nmyObj.addPropHere = 'Hello World!'; // Will throw error\r\n```\r\n\r\n# Querying Objects by props\r\n\r\nProxies are very powerful. They also allow us to access dynamically generated properties.\r\n\r\nLet's look at the following snippet:\r\n\r\n```js\r\nconst arr = rondel.getProtected([\r\n  {\r\n    name: 'John',\r\n    age: 30,\r\n    skills: ['React', 'Node'],\r\n    position: 'Sr Dev',\r\n    salary: 100000,\r\n  },\r\n  { name: 'Mathew', age: 26, skills: ['JavaScript'], salary: 0 },\r\n  {\r\n    name: 'Claudia',\r\n    nationality: null,\r\n    age: 33,\r\n    skills: ['AWS', 'Azure', 'DevOps', 'JavaScript'],\r\n    salary: 80000,\r\n  },\r\n]);\r\n```\r\n\r\nBy using `findWhere<Property>Equals(<String>)` we'll get all the matching results\r\n\r\n```js\r\narr.findWhereNameEquals('John')); // will give us all the object that contains John\r\n```\r\n\r\n## Other Examples\r\n\r\n```js\r\narr.findWhereNationalityIsNull()); // will give us all the object that contains Claudia\r\n```\r\n\r\n```js\r\narr.findWhereSkillsIncludes('JavaScript')); // will give us all the object that contains Mathew\r\n```\r\n\r\nCurrently supported methods:\r\n\r\n**findWhereXEquals**\r\n\r\nReturns an array of objects of all matching <X> objects to value.\r\n\r\n```ts\r\nfindWhereXEquals(value: any) : [{}];\r\n```\r\n\r\n**findWhereXIsNull**\r\n\r\nReturns an array of objects of all matching <X> null objects.\r\n\r\n```ts\r\nfindWhereXIsNull() : [{}];\r\n```\r\n\r\n**findWhereXIsUndefined**\r\n\r\nReturns an array of objects of all matching <X> undefined objects.\r\n\r\n```ts\r\nfindWhereXIsUndefined() : [{}];\r\n```\r\n\r\n**findWhereXIsEmpty**\r\n\r\nReturns an array of objects of all matching <X> Empty objects.\r\n\r\n```ts\r\nfindWhereXIsEmpty() : [{}];\r\n```\r\n\r\n**findWhereXIsIncludes**\r\n\r\nReturns an array of objects of all matching <X> to the value/s provided.\r\n\r\n```ts\r\nfindWhereXIsIncludes(value: any) : [{}];\r\n```\r\n\r\n**findWhereXIsLowerThan** & **findWhereXIsGreaterThan**\r\n\r\nReturns an array of objects of all matching <X> wether is lower or greater than a value provided.\r\n\r\n```ts\r\nfindWhereXIsLowerThan(value: any) : [{}];\r\nfindWhereXIsGreaterThan(value: any) : [{}];\r\n```\r\n","readmeFilename":"README.md"}