Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/okdistribute/yo-fs
A filesystem browser built with yo
https://github.com/okdistribute/yo-fs
Last synced: about 2 months ago
JSON representation
A filesystem browser built with yo
- Host: GitHub
- URL: https://github.com/okdistribute/yo-fs
- Owner: okdistribute
- Created: 2016-06-03T21:04:12.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-25T22:32:03.000Z (about 6 years ago)
- Last Synced: 2024-05-27T12:39:39.332Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 21
- Watchers: 3
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# yo-fs
A client-side modular, stream-friendly ui browser widget for navigating directories, built with [yo-yo](https://www.npmjs.org/yo-yo).
[![NPM](https://nodei.co/npm/yo-fs.png)](https://nodei.co/npm/yo-fs/)
## api
#### `yofs(path, entries, onclick)`
* `path`: the directory or filename to display
* `entries`: a list of entries with `name`, `size`, `modified`, `createReadStream`
* `onclick`: fires when a folder, file, or back button is clicked.## example
```js
var yofs = require('yo-fs')
var yo = require('yo-yo')var entries = []
function onclick (event, entry) {
console.log('i clicked', entry)
}// only create the top-level element once
var el = yofs('/', entries, onclick)
document.body.appendChild(el)// update the tree's internal html widget using yo
function update () {
var fresh = tree.render('/', entries, onclick)
yo.update(tree.widget, fresh)
}var stream = //stream that gives me some data...
stream.on('data', function (entry) {
entries.push(entry)
update()
}
```