UNPKG

4.62 kBSource Map (JSON)View Raw
1{"version":3,"sources":["raze.js"],"names":[],"mappings":"AAAA;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,IAAM,oBAAoB,wBAA1B;;AAEA,IAAM,OAAO,SAAS,IAAT,CAAe,MAAf,EAAuB;AACnC;;;;;;;;AAQA;;;;;AAKA;AACG,QAAO,MAAP,IAAiB,WAAnB;AACE,QAAO,MAAP,IAAiB,QAAjB,IAA6B,OAAO,MAAP,IAAiB,CADhD;AAEE,SAAO,MAAP,uDAAO,MAAP,MAAiB,QAAjB,IAA6B,UAAU,IAFzC;AAGE,QAAO,MAAP,IAAiB,QAAjB,IAA6B,MAAO,MAAP,CAJhC;AAKC;AACA,SAAO,EAAP;AACA;;AAED;;;;;;;;;;;AAWA,KAAI,QAAO,MAAP,uDAAO,MAAP,MAAiB,QAArB,EAA+B;AAC9B,SAAO,CAAE,MAAF,CAAP;AACA;;AAED,KAAG;AACF,MAAI,QAAQ,oBAAY,MAAZ,CAAZ;;AAEA;;;;;;;;AAQA,MAAI,MAAM,MAAN,KAAiB,CAArB,EAAwB;AACvB,OAAI,kBAAkB,IAAlB,MAA4B,MAA5B,CAAJ,EAA6C;AAC5C,WAAO,KAAP;AACA;;AAED,OAAI,MAAM,OAAN,CAAe,MAAf,CAAJ,EAA6B;AAC5B,WAAO,KAAP;AACA;;AAED,UAAO,CAAE,MAAF,CAAP;AACA;;AAED,SAAO,KAAP;;AAEA,EAzBD,CAyBC,OAAO,KAAP,EAAc;AACd,SAAO,EAAP;AACA;AACD,CAlED;;AAoEA,OAAO,OAAP,GAAiB,IAAjB","file":"raze.support.js","sourcesContent":["\"use strict\";\n\n/*;\n\t@module-license:\n\t\tThe MIT License (MIT)\n\t\t@mit-license\n\n\t\tCopyright (@c) 2017 Richeve Siodina Bebedor\n\t\t@email: richeve.bebedor@gmail.com\n\n\t\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\t\tof this software and associated documentation files (the \"Software\"), to deal\n\t\tin the Software without restriction, including without limitation the rights\n\t\tto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\t\tcopies of the Software, and to permit persons to whom the Software is\n\t\tfurnished to do so, subject to the following conditions:\n\n\t\tThe above copyright notice and this permission notice shall be included in all\n\t\tcopies or substantial portions of the Software.\n\n\t\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\t\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\t\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\t\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\t\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\t\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n\t\tSOFTWARE.\n\t@end-module-license\n\n\t@module-configuration:\n\t\t{\n\t\t\t\"package\": \"raze\",\n\t\t\t\"path\": \"raze/raze.js\",\n\t\t\t\"file\": \"raze.js\",\n\t\t\t\"module\": \"raze\",\n\t\t\t\"author\": \"Richeve S. Bebedor\",\n\t\t\t\"eMail\": \"richeve.bebedor@gmail.com\",\n\t\t\t\"contributors\": [\n\t\t\t\t\"John Lenon Maghanoy <johnlenonmaghanoy@gmail.com>\",\n\t\t\t\t\"Vinse Vinalon <vinsevinalon@gmail.com>\"\n\t\t\t],\n\t\t\t\"repository\": \"https://github.com/volkovasystems/raze.git\",\n\t\t\t\"test\": \"raze-test.js\",\n\t\t\t\"global\": true\n\t\t}\n\t@end-module-configuration\n\n\t@module-documentation:\n\t\tConvert entity to Array instance.\n\n\t\tThis will always return a new array.\n\t@end-module-documentation\n*/\n\nconst ARGUMENTS_PATTERN = /^\\[object Arguments\\]$/;\n\nconst raze = function raze( entity ){\n\t/*;\n\t\t@meta-configuration:\n\t\t\t{\n\t\t\t\t\"entity:required\": \"*\"\n\t\t\t}\n\t\t@end-meta-configuration\n\t*/\n\n\t/*;\n\t\t@note:\n\t\t\tIf entity is falsy, return empty array.\n\t\t@end-note\n\t*/\n\tif(\n\t\t( typeof entity == \"undefined\" ) ||\n\t\t( typeof entity == \"string\" && entity.length == 0 ) ||\n\t\t( typeof entity == \"object\" && entity == null ) ||\n\t\t( typeof entity == \"number\" && isNaN( entity ) )\n\t){\n\t\treturn [ ];\n\t}\n\n\t/*;\n\t\t@note:\n\t\t\tAll arrays, array-like, iterable, are object (with rare exception*)\n\n\t\t\tNon-objects take up the first position of the array.\n\n\t\t\t* Functions with Symbol.iterable might be an exception but chances\n\t\t\t\tof this being implemented is rare considering no practical use cases\n\t\t\t\tas of the moment.\n\t\t@end-note\n\t*/\n\tif( typeof entity != \"object\" ){\n\t\treturn [ entity ];\n\t}\n\n\ttry{\n\t\tlet array = Array.from( entity );\n\n\t\t/*;\n\t\t\t@note:\n\t\t\t\tIf the array result is empty, then check if it is an argument entity,\n\t\t\t\t\telse return the entity as the first position in the object because\n\t\t\t\t\tthe object is not absorbed because the object is not array-like or\n\t\t\t\t\titerable.\n\t\t\t@end-note\n\t\t*/\n\t\tif( array.length === 0 ){\n\t\t\tif( ARGUMENTS_PATTERN.test( `${ entity }` ) ){\n\t\t\t\treturn array;\n\t\t\t}\n\n\t\t\tif( Array.isArray( entity ) ){\n\t\t\t\treturn array;\n\t\t\t}\n\n\t\t\treturn [ entity ];\n\t\t}\n\n\t\treturn array;\n\n\t}catch( error ){\n\t\treturn [ ];\n\t}\n};\n\nmodule.exports = raze;\n"]}
\No newline at end of file