Introducing filer.js

ericbidelman:

Some 1300+ lines of code, 106 tests, and a year after I first started it, I’m happy to officially unleash filer.js (https://github.com/ebidel/filer.js); a wrapper library for the HTML5 Filesystem API.

Unlike other libraries [1, 2], filer.js takes a different approach and incorporates some lessons I learned while implementing the Google Docs Python client library. Namely, the library resuses familiar UNIX commands (cp, mv, rm) for its API. My goal was to a.) make the HTML5 API more approachable for developers that have done file I/O in other languages, and b.) make repetitive operations (renaming, moving, duplicating) easier.

So, say you wanted to list the files in a given folder. There’s an ls() for that:

var filer = new Filer();
filer.init({size: 1024 * 1024}, onInit.bind(filer), onError);

function onInit(fs) {
  filer.ls('/', function(entries) {
    // entries is an Array of file/directories in the root folder.
  }, onError);
}

function onError(e) { ... }

A majority of filer.js calls are asynchronous. That’s because the underlying HTML5 API is also asynchronous. However, the library is extremely versatile and tries to be your friend whenever possible. In most cases, callbacks are optional. filer.js is also good at accepting multiple types when working with entries. It accepts entries as string paths, filesystem: URLs, or as the FileEntry/DirectoryEntry object.

For example, ls() is happy to take your filesystem: URL or your DirectoryEntry:

// These will produce the same results.
filer.ls(filer.fs.root.toURL(), function(entries) { ... });
filer.ls(filer.fs.root, function(entries) { ... });
filer.ls('/', function(entries) { ... });

The library clocks in at 24kb (5.6kb compressed). I’ve thrown together a complete sample app to demonstrate most of filer.js’s functionality:

spacer Try the DEMO

Lastly, there’s room for improvement:

  1. Incorporate Chrome’s Quota Management API
  2. Make usage in Web Workers more friendly (there is a synchronous API).

I look forward to your feedback and pull requests!

Source: ericbidelman

  • 1 month ago > ericbidelman
  • 30
  • Permalink
  • Share
    Tweet

Pepatah Bijaksana Mario Teguh dkk

fuckyeahmahasiswa:

Motivasi buat “MAHASISWA” hari ini oleh Mario Teguh dan kawan-kawannya, semoga termotivasi :

“Hentikanlah kebiasaanmu membandingkan kekuranganmu dengan kelebihan orang lain.”
(Mario Teguh)

“Bila anda gagal hari ini, jangan pernah menyerah. Ulangi terus kegagalan anda sampai atasan/komandan anda menyerah.”
(Mario Tegar)

“Jangan pernah menyerah… Benturkanlah kepala anda ditembok atau batu, maka akan keluar darah/minimal benjol.”
(Mario Bross)

“Jika modal usaha Anda habis untuk aktivitas usaha Anda, setor terus modal Anda sekalipun tidak mendatangkan hasil bila kurang gadaikan saja apa yg bisa jd uang.”
(Mario Tekor)

“Tak ada pekerjaan yg berat. Pekerjaan seberat apapun akan terasa ringan apabila tidak dikerjakan”
(Mario Ngeluh)

“Jika anda merasa lelah dengan pekerjaan anda, maka tidurlah, maka 1 masalah sudah terselesaikan.”
(Mario Tepar)


“Jangan pernah mikir kerjaan terus, enjoy ur life, forget about everything that’s bothering u… let’s get this party started!”
(Mari yo Dugem Mareee)

“Mulai dari yang mudah dan ringan, yang rumit dan berat nanti juga ada org lain yang ngerjain…”
(Mario Tega)

“Mulailah dari yang kecil… karena semua yang besar dulunya juga kecil.”
(Mario Erot)

Kesuksesan bisa diraih karena usaha
Usaha ada karena kemauan
Kemauan tercipta karena ada cita-cita
Cita-cita berasal dari mimpi
Mimpi ada karena tidur…
So… Jika ingin sukses marilah kita TIDUR
(Mario Tengil)

“Tak ada pekerjaan yg berat. Jika merasa berat posisikan diri anda jangan di bawah, cobalah di atas. Jika masih terasa berat gantilah pasangan anda.”
(Mario Ozawa)

dari hakiem.ahmad

Source: fuckyeahmahasiswa

  • 4 months ago > fuckyeahmahasiswa
  • 354
  • Permalink
  • Share
    Tweet
Javascript, The world’s most misunderstood programming language.
Douglas Crockford
    • #Javascript
  • 8 months ago
  • Permalink
  • Share
    Tweet

Q:WHAT IS YOUR EARLIEST HUMAN MEMORY?

spacer tumblrbot

sorry, i’ve forgotten that :)

  • 8 months ago
  • Permalink
  • Share
    Tweet

Hello Tumblr World!

Initializing…

  • 8 months ago
  • Permalink
  • Share
    Tweet
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.