{"_id":"@acimini/cm-utils","_rev":"8-e581329facea7d12ecc337b6afb4da89","time":{"created":"2021-01-08T11:12:07.372Z","0.0.2":"2021-01-08T11:12:07.688Z","modified":"2022-04-04T11:11:24.546Z","0.0.3":"2021-01-08T11:52:51.828Z","0.0.4":"2021-02-04T08:50:40.180Z"},"name":"@acimini/cm-utils","dist-tags":{"latest":"0.0.4"},"versions":{"0.0.2":{"name":"@acimini/cm-utils","version":"0.0.2","author":{"name":"Andrea Cimini"},"repository":{"type":"git","url":"git+https://github.com/AndreaCimini/cm-utils.git"},"bugs":{"url":"https://github.com/AndreaCimini/cm-utils/issues"},"keywords":["angular","javascript","typescript","merge","clone","unique","json to typescript","typescript to json","deep find","deep update","deep delete"],"peerDependencies":{"@angular/common":"^7.0.0","@angular/core":"^7.0.0"},"main":"bundles/acimini-cm-utils.umd.js","module":"fesm5/acimini-cm-utils.js","es2015":"fesm2015/acimini-cm-utils.js","esm5":"esm5/acimini-cm-utils.js","esm2015":"esm2015/acimini-cm-utils.js","fesm5":"fesm5/acimini-cm-utils.js","fesm2015":"fesm2015/acimini-cm-utils.js","typings":"acimini-cm-utils.d.ts","metadata":"acimini-cm-utils.metadata.json","sideEffects":false,"dependencies":{"tslib":"^1.10.0"},"description":"CmUtils is a library that contains some utility functions to manage objects and arrays.\\\r With this library we have:\r * functions and pipes that **check if an element is undefined, null or empty** (they work on objects, arrays and variables)\r * function t","homepage":"https://github.com/AndreaCimini/cm-utils#readme","_id":"@acimini/cm-utils@0.0.2","_nodeVersion":"15.2.0","_npmVersion":"6.14.6","dist":{"integrity":"sha512-5LzrCsXp7Ht6UATAg2pOcjs3EUfRG66jOdl3tsXxVTQdj3Yr4d1ieyScHnYQ8O6MN+0Sl8hi8Qh+iEvNZRlESA==","shasum":"333a72a1b8a15d624a0202e09f5ecf9761bb9ad9","tarball":"https://registry.npmjs.org/@acimini/cm-utils/-/cm-utils-0.0.2.tgz","fileCount":41,"unpackedSize":868053,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf+D4HCRA9TVsSAnZWagAA2OkQAJPsScNg1WGDWmCJF6I+\ncZ5VV1zIdPh+bPsH9qnsM7JAZW1lp4WzdKSv7sGL5PE84cJ8qwTVhsIfoszo\nqJmZww0qDoSwM3cl7f4DGdsRtQbzGJz5wUN8M3BRHBYdRVmw4+6MUtKqckij\nW2qzh3FgjrhVeQC3XjH/cohE801Xdsm96mCW/fGtyzsP7Mqr+cafqxJcmAlQ\nAilDU/Gl3JCwjQFIi1nXWf+ww+msEx5r/49zarDdt/ItlgUDb+56w9Vs3O0M\n+A4pZj+WnXZLdvw1MxBXqM8HsdohrLDSDr/T4erdHJ4euqZt/m+AduJt+/Hm\nlOpHZuzc32hbKesrtpmzcACeLV/Q4qzd7oJQipAfGOm+4toa7jApDYTpb1xg\nmnYXrp8yIk7BdJxe7KyAxAvt80/1tBXkeliUQVu6zAjgnW6W6iOTR/+OoeM2\nth4tbSyBaF6FNwFDCnyAAXNBFySdAY7jawGu6we4IW80d97z8cACkxt3rgmA\nk53QuSAPEFOMyTKAmsX6he4rqNVNrJzWnlqBRt1tt1se5kxvlC5DySs4cjbX\nRg7XNbCR/1NixJTh8ErbKECEyZxtq+2iCO4kMTGd3ic3dbvKZaNKNxs2/1PB\n/hs5yUYViBU+a7/syBDOqUEPU4SzuCwpYOkCU5Im5ACl08KZUYM5+NfyfOWs\nkKuD\r\n=X+ik\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGPT/0vpjzbZJmQ2JT1P+iv52Pwa/QiH6b72LX3PiGJVAiBcFo3pzTTEaz1c/pUK70gvti306fY6S6wEBn+13XQ2Bg=="}]},"_npmUser":{"name":"acimini","email":"and.cimini@gmail.com"},"directories":{},"maintainers":[{"name":"acimini","email":"and.cimini@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cm-utils_0.0.2_1610104327410_0.5399970110530838"},"_hasShrinkwrap":false},"0.0.3":{"name":"@acimini/cm-utils","version":"0.0.3","author":{"name":"Andrea Cimini"},"repository":{"type":"git","url":"git+https://github.com/AndreaCimini/cm-utils.git"},"bugs":{"url":"https://github.com/AndreaCimini/cm-utils/issues"},"keywords":["angular","javascript","typescript","merge","clone","unique","json to typescript","typescript to json","deep find","deep update","deep delete"],"license":"Apache","peerDependencies":{"@angular/common":"^9.1.13","@angular/core":"^9.1.13"},"main":"bundles/acimini-cm-utils.umd.js","module":"fesm5/acimini-cm-utils.js","es2015":"fesm2015/acimini-cm-utils.js","esm5":"esm5/acimini-cm-utils.js","esm2015":"esm2015/acimini-cm-utils.js","fesm5":"fesm5/acimini-cm-utils.js","fesm2015":"fesm2015/acimini-cm-utils.js","typings":"acimini-cm-utils.d.ts","metadata":"acimini-cm-utils.metadata.json","sideEffects":false,"dependencies":{"tslib":"^1.10.0"},"description":"CmUtils is a library that contains some utility functions to manage objects and arrays.\\\r With this library we have:\r * functions and pipes that **check if an element is undefined, null or empty** (they work on objects, arrays and variables)\r * function t","homepage":"https://github.com/AndreaCimini/cm-utils#readme","_id":"@acimini/cm-utils@0.0.3","_nodeVersion":"15.2.0","_npmVersion":"6.14.6","dist":{"integrity":"sha512-WelpDM4AVx/3XaKtXm+FbLOMfQH8Y2ehOviH6BPEXcUwpTAsKRmJE7BTqzVEU0mQX1mNAiq9RI5DgpN0dSFnJQ==","shasum":"c60a65ee1de17e20cb83f5452276a51ab0dd13b6","tarball":"https://registry.npmjs.org/@acimini/cm-utils/-/cm-utils-0.0.3.tgz","fileCount":41,"unpackedSize":868223,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf+EeUCRA9TVsSAnZWagAAHlkP/0DAdmg/gVG/6o16YnCY\nt5kpOAV2g0rcmjtkWdhPOcWtP/Xax8EQtkHgx8vLh4Yxi6QdWdqCrvCO3Wnx\noSA0r8kBcijv8sfQUcSktXz79WUoHz2DcWzs6V8xuc1wVoyBBea/vbi/bSDo\nKPUBMdB2yLAnv3BAtDMoDW9P1hozugpd9QHcRGvDAGlqjaAfbPVRD2l+K5uw\niHhS0+eQ8YQnt3k6fr2RC7Q2BLw8yw+h2+cIX1UFTXwk26e2cLB9gvjfrh8V\nba5TfjKltBpQI77JDlyR5YOhK5UNo4gvTRZrGCBCOTBoDoCZpiRlWe9PLx/M\nPWtF54ZiN9Ids9ud0Ugjqpho8rLjCsaN5hlZYOENYDgRpKMxh1jRIYzQa0OL\nb+A5LMllA3rEark4HibdwSVE0+3uf8ab/7VuPhMmhYUyMBgKrs1CeGjROd6h\nFTuRbhVC6mEum6kYhRlQRaf0L1GKv4g+wP0Eni6nJt5hA7Ehxr62MqkaZ9Rn\njSwsvgLdJQQku2SbFEplQIdod0zOL8JzKUEkEiXtU7bHka8F01HVBabvXQDV\nosNPyFfvU/wBK28NPlx/fD4jNMH5+UcG/gZcKpHLu5JzPRDWolwuKaXu8CBb\nHcFV8U98lByKmOim7mknPLPK7FT6sWu3ruI/99OzYDB8tqHNQZm3VE7jO4RI\neLZ2\r\n=H00d\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCM2lxAKJqq3GxDAd7AZiSI5wAF+C5q2l+lFlRVvcrCsQIgXOVETF63Edtew2FYmGI693vlKNIM9wS+/EoCsLsHW/E="}]},"_npmUser":{"name":"acimini","email":"and.cimini@gmail.com"},"directories":{},"maintainers":[{"name":"acimini","email":"and.cimini@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cm-utils_0.0.3_1610106771541_0.09314576147360976"},"_hasShrinkwrap":false},"0.0.4":{"name":"@acimini/cm-utils","version":"0.0.4","author":{"name":"Andrea Cimini"},"repository":{"type":"git","url":"git+https://github.com/AndreaCimini/cm-utils.git"},"bugs":{"url":"https://github.com/AndreaCimini/cm-utils/issues"},"keywords":["angular","javascript","typescript","merge","clone","unique","json to typescript","typescript to json","deep find","deep update","deep delete"],"license":"Apache","peerDependencies":{"@angular/common":"^9.1.13","@angular/core":"^9.1.13"},"main":"bundles/acimini-cm-utils.umd.js","module":"fesm5/acimini-cm-utils.js","es2015":"fesm2015/acimini-cm-utils.js","esm5":"esm5/acimini-cm-utils.js","esm2015":"esm2015/acimini-cm-utils.js","fesm5":"fesm5/acimini-cm-utils.js","fesm2015":"fesm2015/acimini-cm-utils.js","typings":"acimini-cm-utils.d.ts","metadata":"acimini-cm-utils.metadata.json","sideEffects":false,"dependencies":{"tslib":"^1.10.0"},"description":"CmUtils is a library that contains some utility functions to manage objects and arrays.\\\r With this library we have:\r * functions and pipes that **check if an element is undefined, null or empty** (they work on objects, arrays and variables)\r * function t","homepage":"https://github.com/AndreaCimini/cm-utils#readme","_id":"@acimini/cm-utils@0.0.4","_nodeVersion":"15.2.0","_npmVersion":"6.14.6","dist":{"integrity":"sha512-JmBKe4CjMFAV4V4FIKBQn0hf53y76J4IzSOfzFJs+FBtRTczQ/+USEJLPlItA587y1J1SjNiHTFMkHnks3s97w==","shasum":"93d14c75ff07d1c743c0d819d3ba83fee72151e3","tarball":"https://registry.npmjs.org/@acimini/cm-utils/-/cm-utils-0.0.4.tgz","fileCount":41,"unpackedSize":868428,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgG7VgCRA9TVsSAnZWagAACRgP/2RrqELEFTFG7u5uBq4x\nC+xWuaAu+r1j+N1ZeHY45A22C+WH+yg5+4AzwTvghd6nJdvyYE5ieQdvbfPf\nU7rWYtBBmJNNqxD8DDajdsYmeFKlzXUIWVrCd7LuwaTebQ4O/w3U9MdvblLP\nTYh3AHBTs5svKYe/SFnAWVSWwy5Buu+zPIuvf7doAAVT4A96CGoKRkqIrwCz\njQ5PypIX6mWFD5N1x1tikeUbv4MQdjxtQfWlRn4SaONx1g9yI52gRXgemPdZ\nEsclWGD1PFsdQa0RiGkB2+NJnpeZbxzdmht+y3RDv1kUTbIncY0LEZAJOgd/\nC5Lm/aVCTBGHTOfis4rYBbSpXkn9h2BnmTbfkqJWeTGd0DoFZFTdXYFh1cBH\nw59dLEeHZwbeLLYFxIxxN3J1Ap/0PkS5TxAxJVBTVYjPiRy62kyhGKxpnCgt\ntxAknYAUCLs5+XEOclct7l8zw5Si9lA7kTLoaSaEmUpXaF+XpY+ddW0k66Ab\nN2N4LDIXkHmdg5d9n4IOahSxPqoowJQGa+XXynIXGDKOYmhrruIIs0moF/Od\n4RNgmWqzfyF5IU1mkUSMMidzVC1sSMwud5ddf7kpP/wM/S1lLoRqPD7R1WXX\nrDu1fJHK8xvTVdlr9AfwBy24YJPCvvTNJ5q/WR2+CdotxHgw87Dcdcqu18Nq\n9WFI\r\n=6ZI2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCDbaYcI5NjAkPz7kLVLSX6djM3SJxP0bhrf9ZDh9ktpAIgTFHq9cDv9ZlLISQVqrLAhCgh2NR0SS6ytL+oqWWwhtY="}]},"_npmUser":{"name":"acimini","email":"and.cimini@gmail.com"},"directories":{},"maintainers":[{"name":"acimini","email":"and.cimini@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cm-utils_0.0.4_1612428640009_0.655911969557218"},"_hasShrinkwrap":false}},"maintainers":[{"name":"acimini","email":"and.cimini@gmail.com"}],"description":"CmUtils is a library that contains some utility functions to manage objects and arrays.\\\r With this library we have:\r * functions and pipes that **check if an element is undefined, null or empty** (they work on objects, arrays and variables)\r * function t","homepage":"https://github.com/AndreaCimini/cm-utils#readme","keywords":["angular","javascript","typescript","merge","clone","unique","json to typescript","typescript to json","deep find","deep update","deep delete"],"repository":{"type":"git","url":"git+https://github.com/AndreaCimini/cm-utils.git"},"author":{"name":"Andrea Cimini"},"bugs":{"url":"https://github.com/AndreaCimini/cm-utils/issues"},"readme":"# CmUtils\r\n\r\nCmUtils is a library that contains some utility functions to manage objects and arrays.\\\r\nWith this library we have:\r\n* functions and pipes that **check if an element is undefined, null or empty** (they work on objects, arrays and variables)\r\n* function to **merge two objects or two arrays**\r\n* function to **clone an object**\r\n* functions to **remove duplicates in an array** and **check if two elements are equal**\r\n* function to **convert a json (maybe from an api) to a specific typescript class** and vice versa\r\n* functions to **find, update and remove** properties deep into an object\r\n\r\nThis is based on:\r\n* [Angular 9](https://angular.io)\r\n\r\n## Index\r\n\r\n1. [Install](#install)\r\n2. [How to use](#how-to-use)\r\n3. [Utility functions](#utility-functions)\r\n    * [isUndefined](#isundefined)\r\n    * [isNull](#isnull)\r\n    * [isNil](#isnil)\r\n    * [isEmpty](#isempty)\r\n    * [isNilty](#isnilty)\r\n    * [merge](#merge)\r\n    * [cloneClass](#cloneclass)\r\n    * [isEqual](#isequal)\r\n    * [uniqueBy](#uniqueby)\r\n    * [deserialize](#deserialize)\r\n    * [serialize](#serialize)\r\n    * [deepFind](#deepfind)\r\n    * [deepUpdate](#deepupdate)\r\n    * [deepRemove](#deepremove)\r\n4. [Pipes](#pipes)\r\n5. [Authors](#authors)\r\n6. [License](#license)\r\n\r\n## Install\r\n\r\n``npm install @acimini/cm-utils --save``\r\n\r\nImport in your app\r\n\r\n```javascript\r\nimport { CmUtilsModule } from '@acimini/cm-utils';\r\n\r\n@NgModule({\r\n  imports: [ CmUtilsModule ],\r\n  ...\r\n})\r\n```\r\n\r\n## How to use\r\n\r\n#### First define your model\r\n\r\n ```javascript\r\n import {CmUtilsProperty} from '@acimini/cm-utils';\r\n\r\n class SubClassName {\r\n   @CmUtilsProperty(String) subkey1: string;\r\n   @CmUtilsProperty(Boolean) subkey2: boolean;\r\n }\r\n \r\n class ClassName {\r\n   @CmUtilsProperty(String) key1: string;\r\n   @CmUtilsProperty(SubClassName) key2: SubClassName;\r\n   @CmUtilsProperty(Number) key3: number;\r\n   @CmUtilsProperty(String) key4: string[];\r\n   @CmUtilsProperty(SubClassName) key5: SubClassName[];\r\n }\r\n ```\r\n\r\nThe first parameter in CmUtilsProperty decorator tells to utility functions what is the type of the property.\\\r\nBelow the table that compares the typescript type with the type for the decorator:\r\n\r\n| Decorator type            | TypeScript type       |\r\n| ---                       | ---                   |\r\n| String                    | string                |\r\n| Number                    | number                |\r\n| Boolean                   | boolean               | \r\n| ClassName                 | ClassName             |\r\n| Any                       | any                   |\r\n| Multi                     | multi types           |\r\n| Tuple                     | tuple types           |\r\n\r\n###### Multi types\r\n\r\nMulti types are used for those variables that can have multi types at same time. For example a variable that can be a string, or a number.\\\r\nIn this case model definition will be\r\n\r\n ```javascript\r\n import {CmUtilsProperty, Multi} from '@acimini/cm-utils';\r\n\r\n class ClassName {\r\n   @CmUtilsProperty(new Multi(String, Number)) key1: string | number;\r\n }\r\n ```\r\n\r\n###### Tuple types\r\n\r\nTuple types are used for those variables that are arrays with defined number of elements of different types. For example a variable that is an array with first element as string and second element as number.\\\r\nIn this case model definition will be\r\n\r\n ```javascript\r\n import {CmUtilsProperty, Tuple} from '@acimini/cm-utils';\r\n\r\n class ClassName {\r\n   @CmUtilsProperty(new Tuple(String, Number)) key1: [string, number];\r\n }\r\n ```\r\n\r\n#### Use utility functions\r\n\r\n ```javascript\r\n import {CmUtilsService} from '@acimini/cm-utils';\r\n\r\n const firstObj = new ClassName();\r\n const secondObj = new ClassName();\r\n ...\r\n \r\n const newObj = CmUtilsService.mergeObj(firstObj, secondObj);\r\n ...\r\n  ```\r\n\r\n## Utility functions\r\n\r\n### isUndefined\r\n\r\nChecks if an element is undefined.\r\n\r\n ```javascript\r\n const elem = new ClassName();\r\n...\r\n CmUtilsService.isUndefined(elem) \r\n  ```\r\n\r\nIt returns true if it is undefined, false otherwise\r\n\r\n### isNull\r\n\r\nChecks if an element is null.\r\n\r\n ```javascript\r\n const elem = new ClassName();\r\n...\r\n CmUtilsService.isNull(elem) \r\n  ```\r\nIt returns true if it is null, false otherwise\r\n\r\n### isNil\r\n\r\nChecks if an element is null or undefined.\r\n\r\n ```javascript\r\n const elem = new ClassName();\r\n...\r\n CmUtilsService.isNil(elem) \r\n  ```\r\nIt returns true if it is undefined or null, false otherwise\r\n\r\n### isEmpty\r\n\r\nChecks if an element is empty. It can be used with strings, arrays and objects.\r\n\r\n ```javascript\r\n const elem = new ClassName();\r\n...\r\n CmUtilsService.isEmpty(elem) \r\n  ```\r\n It returns true if it is empty, false otherwise\r\n \r\n### isNilty\r\n\r\nChecks if an element is null or undefined or empty. It can be used with strings, arrays and objects.\r\n\r\n ```javascript\r\n const elem = new ClassName();\r\n...\r\n CmUtilsService.isNilty(elem)\r\n  ```\r\nIt returns true if it is undefined or null or empty, false otherwise \r\n \r\n### merge\r\n\r\nMerge two items (arrays or objects).\r\n\r\n ```javascript\r\n const firstItem: ClassName = new ClassName();\r\n const secondItem: ClassName = new ClassName();\r\n...\r\n CmUtilsService.merge(firstItem, secondItem)\r\n  ```\r\nIt merges the first item into the second item.\r\n\r\n##### array merge strategy\r\n\r\nBy default, array are merged pushing in destination array those elements that are in source array and aren't in destination array. For example:\r\n\r\n `[1,3,5] merged into [1,2,3] become [1,2,3,5]`\r\n \r\nIt's possible to change this behaviour in two ways:\r\n* passing a merger function as third parameter in merge method\r\n* passing a merger function into CmUtilsProperty decorator\r\n\r\nIn both cases merger function must be defined in this way:\r\n \r\n```javascript\r\nfunction merger (item, sourceArray, destinationArray) {\r\n    // do something \r\n}\r\n  ```\r\n\r\nFirst case is useful if we call merge method to merge two arrays, or we want to merge two objects and apply the same merge strategy for all properties that are arrays.\r\n\r\n```javascript\r\nfunction merger (item, sourceArray, destinationArray) {\r\n    // do something \r\n}\r\n\r\nCmUtilsService.merge(firstArray, secondArray, merger)\r\n  ```\r\n\r\nSecond case is useful if we want to merge two objects and apply different merge strategy for different properties.\r\n\r\n```javascript\r\nclass ClassName {\r\n   @CmUtilsProperty(String) key1: string;\r\n   @CmUtilsProperty(Number) key2: number;\r\n   @CmUtilsProperty(String, {arrayMerger: merger}) key3: string[];\r\n }\r\n\r\nfunction merger (item, sourceArray, destinationArray) {\r\n    // do something \r\n}\r\n\r\nconst firstObject: ClassName = new ClassName();\r\nconst secondObject: ClassName = new ClassName();\r\n\r\nCmUtilsService.merge(firstObject, secondObject)\r\n  ```\r\nIt is possible both define a custom merger as third parameter of the merge method and other mergers as property in decorators.\\\r\nIn this case the first merger is used until the property doesn't have its own.\r\n\r\n### cloneClass\r\n\r\nClone an object with specific class. \\\r\nIt is possible to pass, as second parameter, a different class. If it is not provided, the cloned object will have the same class of that used for cloning.\r\n\r\n ```javascript\r\n const obj: ClassName = new ClassName();\r\n...\r\n CmUtilsService.cloneClass(obj, optionalClass)\r\n  ```\r\n\r\nIt returns the cloned object.\r\n\r\nN.B. The second parameter is useful when the class used for cloning has more or fewer properties than the class of the result object, and the properties in common have the same types. This means that this method is useless if the properties in common have different types (for that case check the serializer method).\r\n\r\n### isEqual\r\n\r\nChecks if two items are equal.\r\n\r\n ```javascript\r\n const firstElem: ClassName = new ClassName();\r\n const secondElem: ClassName = new ClassName();\r\n...\r\n CmUtilsService.isEqual(firstElem, secondElem)\r\n  ```\r\n\r\nIt returns true if the elements are equal, false otherwise.\r\n\r\n### uniqueBy\r\n\r\nCheck for duplicates in array and remove them. \\\r\nIt is possible to use a function to define the strategy used to remove equal elements (for example we want remove the elements that have the same value for a specific key). If it is not provided, the default one will be used and only the elements perfectly equal will be removed.\r\n\r\n ```javascript\r\n const array: ClassName[] = [];\r\n...\r\n CmUtilsService.uniqueBy(array, optionalFunction)\r\n  ```\r\n\r\n### deserialize\r\n\r\nConvert a json into a specific class (it can be used also to convert class into another).\r\n\r\n ```javascript\r\n const json = {};\r\n...\r\n CmUtilsService.deserializer(json, ClassName)\r\n  ```\r\n\r\nIt returns the deserialized object.\r\n\r\n#### property decorator configuration\r\n\r\nIf the property in json is the same (for the name and type) of the property in **ClassName** the decorator configuration is the default one:\r\n\r\n ```javascript\r\n class ClassName {\r\n   @CmUtilsProperty(String) key1: string;\r\n }\r\n ```\r\n\r\nIf the property in json has different type or name or both, the decorator configuration will be:\r\n\r\n ```javascript\r\n class ClassName {\r\n   @CmUtilsProperty(String, undefined, {propertyType: Number, propertyKey: 'key1different'}) key1: string;\r\n }\r\n ```\r\n\r\nWhere **propertyType** defines the type and **propertyKey** defines the name of the property in the json object. \\\r\nIn case of the **propertyType** is not a primitive type (see table in [How to use](#how-to-use) section), or it is necessary to do some operation to convert the value, it is possible define a custom converter. \\\r\n\r\n ```javascript\r\n class ClassName {\r\n   @CmUtilsProperty(String, undefined, {propertyType: Number, converter: new NumberToStringConverter()}) key1: string;\r\n }\r\n ```\r\nWhere **converter** must be defined in this way:\r\n\r\n```javascript\r\nclass NumberToStringConverter implements CustomConverter<String> {\r\n  serialize(data: String): any {\r\n  }\r\n\r\n  deserialize(data: any): String {\r\n    return data.toString().replace('.', ',');\r\n  }\r\n\r\n}\r\n  ```\r\n\r\nEach **converter** must implement **CustomConverter** interface and must have two methods:\r\n* serialize (see [serialize](#serialize) section)\r\n* deserialize\r\n\r\nThe **deserialize method** takes the json value of the property and returns the transformed value.\r\n\r\nN.B.: The converter can be defined also on an array, and an object type property. \\\r\nIn this case, the same converter is applied on each element/property of the array/object that doesn't have its own converter.\r\n\r\n### serialize\r\n\r\nConvert a specific class into a json.\r\n\r\n ```javascript\r\n class ClassName {\r\n  ...   \r\n }\r\n...\r\n CmUtilsService.serializer(ClassName)\r\n  ```\r\n\r\nIt returns the serialized json.\r\n\r\n#### property decorator configuration\r\n\r\nIf the property in **ClassName** is the same (for the name and type) of the property in json the decorator configuration is the default one:\r\n\r\n ```javascript\r\n class ClassName {\r\n   @CmUtilsProperty(String) key1: string;\r\n }\r\n ```\r\n\r\nIf the property in **ClassName** has different type or name or both, the decorator configuration will be:\r\n\r\n ```javascript\r\n class ClassName {\r\n   @CmUtilsProperty(String, undefined, {propertyType: Number, propertyKey: 'key1different'}) key1: string;\r\n }\r\n ```\r\n\r\nWhere **propertyType** defines the type and **propertyKey** defines the name of the property in the json object. \\\r\nIn case of the **propertyType** is not a primitive type (see table in [How to use](#how-to-use) section), or it is necessary to do some operation to convert the value, it is possible define a custom converter. \\\r\n\r\n ```javascript\r\n class ClassName {\r\n   @CmUtilsProperty(String, undefined, {propertyType: Number, converter: new NumberToStringConverter()}) key1: string;\r\n }\r\n ```\r\nWhere **converter** must be defined in this way:\r\n\r\n```javascript\r\nclass NumberToStringConverter implements CustomConverter<Number> {\r\n  serialize(data: String): Number {\r\n    return Number(data.replace(',', '.'));\r\n  }\r\n\r\n  deserialize(data: Number): String {\r\n    return undefined;\r\n  }\r\n\r\n}\r\n  ```\r\n\r\nEach **converter** must implement **CustomConverter** interface and must have two methods:\r\n* serialize\r\n* deserialize (see [deserialize](#deserialize) section)\r\n\r\nThe **serialize method** takes the **ClassName** value of the property and returns the transformed value.\r\n\r\nN.B.: The converter can be defined also on an array, and an object type property. \\\r\nIn this case, the same converter is applied on each element/property of the array/object that doesn't have its own converter.\r\n\r\n### deepFind\r\n\r\nGiven an object, returns the value of the property at a specific path.\r\n\r\n ```javascript\r\n const obj = new ClassName();\r\n...\r\n CmUtilsService.deepFind(obj, 'path.to.key')\r\n  ```\r\nN.B.: the path must start from the root of the object and each level must be separated by a dot. \\\r\nFor arrays, the key is the index of the element.\r\n\r\n### deepUpdate\r\n\r\nGiven an object, update the value of the property at a specific path.\r\n\r\n ```javascript\r\n const obj = new ClassName();\r\n...\r\n CmUtilsService.deepUpdate(obj, 'path.to.key', newValue)\r\n  ```\r\nN.B.: the path must start from the root of the object and each level must be separated by a dot. \\\r\nFor arrays, the key is the index of the element.\r\n\r\n### deepRemove\r\n\r\nGiven an object, remove the property at a specific path.\r\n\r\n ```javascript\r\n const obj = new ClassName();\r\n...\r\n CmUtilsService.deepRemove(obj, 'path.to.key')\r\n  ```\r\nN.B.: the path must start from the root of the object and each level must be separated by a dot. \\\r\nFor arrays, the key is the index of the element.\r\n\r\n## Pipes\r\n\r\nThe library also provides the following pipes:\r\n* **isUndefined**: check if element is undefined\r\n* **isNull**: check if element is null\r\n* **isNil**: check if element is null or undefined\r\n* **isEmpty**: check if element is empty\r\n* **isNilty**: check if element is null or undefined or empty\r\n\r\n## Authors\r\n\r\n* **Andrea Cimini**\r\n\r\n## License\r\n\r\nThis project is licensed under the Apache License 2.0 - see the [LICENSE.md](LICENSE.md) file for details.\r\n","readmeFilename":"README.md","license":"Apache"}