Skip to content

Instantly share code, notes, and snippets.

View panda4man's full-sized avatar

Andrew Clinton panda4man

View GitHub Profile
angular.module('qAllSettled', []).config(function($provide) {
$provide.decorator('$q', function($delegate) {
var $q = $delegate;
$q.allSettled = function(promises) {
return $q.all(promises.map(function(promise) {
return promise.then(function(value) {
return { state: 'fulfilled', value: value };
}, function(reason) {
return { state: 'rejected', reason: reason };
});
//Filesystem (checkDir, createDir, checkFile, creatFile, removeFile, writeFile, readeFile)
.factory('FileService', function($q) {
return {
checkDir: function (dir) {
var deferred = $q.defer();
getFilesystem().then(
function(filesystem) {
filesystem.root.getDirectory(dir, {create: false},