{"id":13622987,"url":"https://github.com/colgatto/Poliparser","last_synced_at":"2025-04-15T10:32:04.129Z","repository":{"id":35151628,"uuid":"213239493","full_name":"colgatto/Poliparser","owner":"colgatto","description":"The only parser you need","archived":false,"fork":false,"pushed_at":"2023-03-03T07:43:00.000Z","size":269,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T04:23:40.552Z","etag":null,"topics":["css-selector","dom","dom-parser","parser","regex","text-parsing"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/colgatto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-06T20:32:51.000Z","updated_at":"2023-03-27T17:43:03.000Z","dependencies_parsed_at":"2024-08-01T21:43:25.253Z","dependency_job_id":"73b7f264-afdd-4eb9-8fef-53c8c018fb75","html_url":"https://github.com/colgatto/Poliparser","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colgatto%2FPoliparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colgatto%2FPoliparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colgatto%2FPoliparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colgatto%2FPoliparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/colgatto","download_url":"https://codeload.github.com/colgatto/Poliparser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249051720,"owners_count":21204872,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css-selector","dom","dom-parser","parser","regex","text-parsing"],"created_at":"2024-08-01T21:01:26.686Z","updated_at":"2025-04-15T10:32:03.860Z","avatar_url":"https://github.com/colgatto.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"![logo](https://i.imgur.com/8mRQA7i.jpg)\n\n[![Build Status](https://travis-ci.org/colgatto/Poliparser.svg?branch=master)](https://travis-ci.org/colgatto/Poliparser)\n[![Coverage Status](https://coveralls.io/repos/github/colgatto/Poliparser/badge.svg?branch=master)](https://coveralls.io/github/colgatto/Poliparser?branch=master)\n![npm](https://badgen.net/npm/dt/poliparser)\n[![license](https://badgen.net/npm/license/poliparser)](https://github.com/colgatto/RWTFPL)\n![size](https://badgen.net/packagephobia/publish/poliparser)\n[![npm](https://badgen.net/badge/icon/npm?icon=npm\u0026label)](https://www.npmjs.com/package/poliparser)\n\nPoliparse is used to extract and parse data from strings, files, urls and many other objects in a simple and fast way.\n\nThe Default modules allows you to parse:\n- String\n- Array\n- Object\n- DOM Elements\n- JSON\n- CSV\n- Hash \u0026 Chipertext\n\nYou can use the default modules or easily add your custom one ( see all the modules on the [Examples](https://github.com/colgatto/Poliparser/tree/master/Examples) page ).\n\n## **Install**\n\n```\nnpm install --save poliparser \n```\n\n## **Usage**\n\nImport and Instantiate Poliparser\n\n```js\nconst Poliparser = require('poliparser');\n\nlet p = new Poliparser();\n```\n\nset a parser template,\nIn this example is used the module `between` from `str` library.\n\n```js\np.setParser({\n\tm: 'str_between',\n\tfrom: '\u003ctitle\u003e',\n\tto: '\u003c/title\u003e'\n});\n```\n\n```js\nlet data = `\u003ctitle\u003ehello\u003c/title\u003e\n\t\u003cdiv class=\".container\"\u003e\n\t\t\u003ca href=\"link1.html\"\u003elink1\u003c/a\u003e\n\t\u003c/div\u003e`;\n\nlet output = p.parse(data);\n\nconsole.log(output);\n```\n**output**\n```js\nhello\n```\n\n---\n\n\u003eps. The fastest way is to pass it in the declaration like this\n\n```js\nlet p = new Poliparser({\n\tm: 'between',\n\tfrom: '\u003ctitle\u003e',\n\tto: '\u003c/title\u003e'\n});\n```\n## **[Documentation](https://github.com/colgatto/Poliparser/tree/master/docgen#documentation)**\n\n**See [Here](https://github.com/colgatto/Poliparser/tree/master/docgen#documentation) for complete modules documentation and [Here](https://github.com/colgatto/Poliparser/tree/master/Examples#real-world-examples) for real world examples.**\n\n### Add Module\n\nYou can use `setModule()` and `requireModule()` to add custom modules.\n\n```js\nlet p = new Poliparser();\n\np.setModule('my_parse_module', (data, block) =\u003e {\n\treturn data.map(x =\u003e x * block.value);\n});\n\np.setParser({\n\tm: 'my_parse_module',\n\tvalue: 3\n});\n\nlet out = p.parse([1,2,3]);\n\nconsole.log(out);\n```\n\nsame as\n\n```js\nlet p = new Poliparser();\n\np.requireModule('my_parse_module', 'myModule.js');\n\np.setParser({\n\tm: 'my_parse_module',\n\tvalue: 3\n});\n\nlet out = p.parse([1,2,3]);\n\nconsole.log(out);\n```\n\n```js\n//myModule.js\nmodule.exports = (data, block) =\u003e {\n\treturn data.map(x =\u003e x * block.value);\n};\n```\n\n**output**\n```js\n[ 3, 6, 9 ]\n```\n\n### Add Library\n\nYou can add a new library with the setLibrary or requireLibrary method.\n\n```js\nlet p = new Poliparser();\n\np.setLibrary('myLib', {\n\tmul: (data, block) =\u003e {\n\t\treturn data * block.value;\n\t},\n\tsum: (data, block) =\u003e {\n\t\treturn data + block.value;\n\t}\n});\n\np.setParser([{\n\tm: 'myLib_mul',\n\tvalue: 3\n},{\n\tm: 'myLib_sum',\n\tvalue: 2\n}]);\n\nlet out = p.parse(10);\n\nconsole.log(out);\n```\n\nsame as\n\n```js\nlet p = new Poliparser();\n\np.requireLibrary('myLib', 'myLib.js');\n\np.setParser([{\n\tm: 'myLib_mul',\n\tvalue: 3\n},{\n\tm: 'myLib_sum',\n\tvalue: 2\n]);\n\nlet out = p.parse(10);\n\nconsole.log(out);\n```\n\n```js\n//myLib.js\nmodule.exports = {\n\tmul: (data, block) =\u003e {\n\t\treturn data * block.value;\n\t},\n\tsum: (data, block) =\u003e {\n\t\treturn data + block.value;\n\t}\n}\n```\n\n**output**\n\n```js\n32\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolgatto%2FPoliparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcolgatto%2FPoliparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolgatto%2FPoliparser/lists"}