{"id":16720902,"url":"https://github.com/yoavniran/html-dir-content","last_synced_at":"2025-03-21T21:30:40.357Z","repository":{"id":26073496,"uuid":"107264525","full_name":"yoavniran/html-dir-content","owner":"yoavniran","description":"Tiny, dependency-free library to (recursively) iterate directory entries in the browser (html5 File System API)","archived":false,"fork":false,"pushed_at":"2023-01-06T01:41:37.000Z","size":748,"stargazers_count":10,"open_issues_count":8,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T05:11:53.358Z","etag":null,"topics":["directory","filesystem","html","html5","javascript","npm"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yoavniran.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}},"created_at":"2017-10-17T12:18:37.000Z","updated_at":"2025-02-25T17:17:34.000Z","dependencies_parsed_at":"2022-07-27T06:16:24.112Z","dependency_job_id":null,"html_url":"https://github.com/yoavniran/html-dir-content","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoavniran%2Fhtml-dir-content","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoavniran%2Fhtml-dir-content/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoavniran%2Fhtml-dir-content/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoavniran%2Fhtml-dir-content/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yoavniran","download_url":"https://codeload.github.com/yoavniran/html-dir-content/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244874094,"owners_count":20524572,"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":["directory","filesystem","html","html5","javascript","npm"],"created_at":"2024-10-12T22:27:25.952Z","updated_at":"2025-03-21T21:30:40.027Z","avatar_url":"https://github.com/yoavniran.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HTML DIR CONTENT\n\n[![npm version](https://badge.fury.io/js/html-dir-content.svg)](https://www.npmjs.com/package/html-dir-content)\n[![CircleCI](https://circleci.com/gh/yoavniran/html-dir-content.svg?style=svg)](https://circleci.com/gh/yoavniran/html-dir-content)\n[![Coverage Status](https://coveralls.io/repos/github/yoavniran/html-dir-content/badge.svg?branch=master)](https://coveralls.io/github/yoavniran/html-dir-content?branch=master)\n\n**Tiny, dependency-free library to (recursively) iterate directory entries in the browser (html5 File System API)**\n\n\n### Install\n\nIn Node/Webpack environment:\n```\n    npm i html-dir-content\n    OR\n    yarn add html-dir-content\n```\n\nDirectly in the browser:\n```\n    \u003cscript src=\"https://unpkg.com/html-dir-content/dist/html-dir-content.min.js\"\u003e\u003c/script\u003e\n```\n\n### API\n\n#### getFiles\n   \n`getFiles(item:[DataTransferItem](https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem), options?: Options) : Promise\u003cArray\u003cFile\u003e\u003e`\n\nReturns a promise of an array of files in case the provided item\nrepresents a directory and the FS API returns children files for it.\n\n- Options: Boolean | Object\n\n    (In case of boolean value, it will be used for the recursive config)\n    - recursive (default: false) - whether to recursively follow the dir structure\n    - bail (default: 1000) - how many levels to follow recursively before bailing\n    - withFullPath (default: false) - file names contain the full file path\n\n#### getFilesFromDragEvent\n    \n`getFilesFromDragEvent(evt: [DragEvent](https://developer.mozilla.org/en-US/docs/Web/Events/drop), options?: Options)`\n\nReturns a promise of an array of files for the given event.\nIn case the event [dataTransfer](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer) property contains file system entries\nand at least one of them is represents a directory and the FS API returns children files for it.\n\n- Options: Boolean | Object\n\n    (In case of boolean value, it will be used for the recursive config)\n    - recursive (default: false) - whether to recursively follow the dir structure\n    - bail (default: 1000) - how many levels to follow recursively before bailing\n    - withFullPath (default: false) - file names contain the full file path\n\n\u003e note: The order of files returned is not guaranteed to be in same order the files on the file system are organized\n\n\u003e note: Firefox will turn any path delimiter (/) in the File name property to \":\" (when using 'withFullPath') :\\( - So in case you need to parse/save the path you can use the custom 'hdcFullPath' prop on the File object  or replace the colons with slashes if needed.\n\n### Example\n\ncheck out this [codepen](https://codepen.io/poeticGeek/pen/xXmPyX).\n\nyour HTML:\n\n``` html\n        \u003cscript src=\"\u003cpath-to-node_modules\u003e/html-dir-content/dist/html-dir-content.min.js\"\u003e\u003c/script\u003e\n```\n\nyour Javascript:\n\n``` javascript\n\n    window.addEventListener(\"drop\", (e) =\u003e {\n                e.preventDefault();\n\n                htmlDirContent.getFilesFromDragEvent(e, true) //will perform recusrive traversal\n                    .then((files) =\u003e {\n                        console.log(\"we have the files: \", files);\n                    });\n            });\n```\n\nor with import/require:\n\n``` javascript\n\n    import {getFilesFromDragEvent} from \"html-dir-content\";\n    .\n    .\n    .\n    getFilesFromDragEvent(e, true)\n        .then((files) =\u003e {\n\n        });\n```\n\nYou can drag a directory (ex: from File Explorer / Finder) and the resolved files array will contain the files contained within it and its sub folders\n\n### Dependencies\n\nRequires global [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) object to be available\n\n\u003e Works on Chrome, Firefox, Safari (at least from version 13), and Edge (no support on IE11)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoavniran%2Fhtml-dir-content","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoavniran%2Fhtml-dir-content","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoavniran%2Fhtml-dir-content/lists"}