Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cordova-promise-fs

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-promise-fs - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

dist/CordovaPromiseFS.js

4

bower.json
{
"name": "cordova-promise-fs",
"main": "CordovaPromiseFS.js",
"version": "0.4.1",
"main": "dist/CordovaPromiseFS.js",
"version": "0.5.0",
"homepage": "https://github.com/markmarijnissen/cordova-promise-fs",

@@ -6,0 +6,0 @@ "authors": [

@@ -48,5 +48,6 @@ /**

options.concurrency = options.concurrency || 3;
options.retry = options.retry || [];
/* Cordova deviceReady promise */
var deviceReady = new Promise(function(resolve,reject){
/* Cordova deviceready promise */
var deviceready = new Promise(function(resolve,reject){
document.addEventListener("deviceready", resolve, false);

@@ -58,6 +59,7 @@ setTimeout(function(){ reject(new Error('deviceready has not fired after 5 seconds.')); },5100);

/* the filesystem! */
var fs = deviceReady.then(function(){
return new Promise(function(resolve,reject){
var fs = new Promise(function(resolve,reject){
deviceready.then(function(){
window.requestFileSystem(options.persistent? 1: 0, options.storageSize, resolve, reject);
});
setTimeout(function(){ reject(new Error('Could not retrieve FileSystem after 5 seconds.')); },5100);
},reject);
});

@@ -68,2 +70,4 @@

window.__fs = fs;
},function(err){
console.error('Could not get Cordova FileSystem:',err);
});

@@ -139,6 +143,6 @@

options = options || {};
return fs.then(function(fs){
return new Promise(function(resolve,reject){
return new Promise(function(resolve,reject){
return fs.then(function(fs){
fs.root.getFile(path,options,resolve,reject);
});
},reject);
});

@@ -150,4 +154,4 @@ }

options = options || {};
return fs.then(function(fs){
return new Promise(function(resolve,reject){
return new Promise(function(resolve,reject){
return fs.then(function(fs){
if(!path || path === '/') {

@@ -158,3 +162,3 @@ resolve(fs.root);

}
});
},reject);
});

@@ -252,2 +256,3 @@ }

function list(path,mode) {
mode = mode || '';
var recursive = mode.indexOf('r') > -1;

@@ -262,4 +267,4 @@ var getAsEntries = mode.indexOf('e') > -1;

return dir(path).then(function(dirEntry){
return new Promise(function(resolve,reject){
return new Promise(function(resolve,reject){
return dir(path).then(function(dirEntry){
var dirReader = dirEntry.createReader();

@@ -284,3 +289,3 @@ dirReader.readEntries(function(entries) {

}, reject);
});
},reject);
});

@@ -318,20 +323,41 @@ }

// Promise callback to check if there are any more queued transfers
function nextTransfer(){
function nextTransfer(result){
inprogress--; // decrement counter to free up one space to start transfers again!
popTransferQueue(); // check if there are any queued transfers
return result;
}
function filetransfer(isDownload,serverUrl,localPath,options,onprogress){
if(typeof options === 'function') {
onprogress = options;
options = {};
function filetransfer(isDownload,serverUrl,localPath,transferOptions,onprogress){
if(typeof transferOptions === 'function') {
onprogress = transferOptions;
transferOptions = {};
}
options = options || {};
serverUrl = encodeURI(serverUrl);
localPath = toInternalURLSync(localPath);
transferOptions = transferOptions || {};
if(!transferOptions.retry || !transferOptions.retry.length) {
transferOptions.retry = options.retry.concat();
}
var ft = new FileTransfer();
var promise = new Promise(function(resolve,reject){
serverUrl = encodeURI(serverUrl);
localPath = toInternalURLSync(localPath);
transferQueue.push([ft,isDownload,serverUrl,localPath,resolve,reject,options.trustAllHosts || false,options]);
popTransferQueue();
}).then(nextTransfer,nextTransfer);
var attempt = function(err){
if(transferOptions.retry.length === 0) {
reject(err);
} else {
transferQueue.unshift([ft,isDownload,serverUrl,localPath,resolve,attempt,transferOptions.trustAllHosts || false,transferOptions]);
var timeout = transferOptions.retry.shift();
if(timeout > 0) {
setTimeout(nextTransfer,timeout);
} else {
nextTransfer();
}
}
};
transferOptions.retry.unshift(0);
inprogress++;
attempt();
});
promise.then(nextTransfer,nextTransfer);
if(typeof onprogress === 'function') ft.onprogress = onprogress;

@@ -380,2 +406,3 @@ promise.progress = function(onprogress){

toDataURL:toDataURL,
deviceready: deviceready,
options: options,

@@ -382,0 +409,0 @@ Promise: Promise

{
"name": "cordova-promise-fs",
"version": "0.4.1",
"version": "0.5.0",
"description": "Cordova FileSystem convienence functions that return promises.",
"main": "index.js",
"scripts": {
"prepublish":"gluejs --include index.js --global CordovaPromiseFS > CordovaPromiseFS.js",
"prepublish":"webpack index.js dist/CordovaPromiseFS.js --output-library CordovaPromiseFS --output-library-target var",
"test": "echo \"Error: no test specified\" && exit 1"

@@ -9,0 +9,0 @@ },

@@ -14,6 +14,5 @@ cordova-promise-fs

npm install cordova-promise-fs
# or just download and include the javascript
curl https://raw.githubusercontent.com/markmarijnissen/cordova-file-cache/master/CordovaFileCache.js
# install Cordova plugins
# install Cordova and plugins
cordova platform add ios@3.7.0
cordova plugin add org.apache.cordova.file

@@ -23,2 +22,6 @@ cordova plugin add org.apache.cordova.file-transfer # optional

**IMPORTANT:** For iOS, use Cordova 3.7.0 or higher (due to a [bug](https://github.com/AppGyver/steroids/issues/534) that affects requestFileSystem).
Or just download and include [CordovaPromiseFS.js](https://raw.githubusercontent.com/markmarijnissen/cordova-promise-fs/master/dist/CordovaPromiseFS.js).
## Usage

@@ -101,2 +104,7 @@

### 0.5.0 (06/11/2014)
* Use `webpack` for the build proces
* Fixed many small bugs
### 0.4.0 (06/11/2014)

@@ -119,3 +127,3 @@

```bash
npm install gluejs -g
npm install webpack -g
npm run-script prepublish

@@ -122,0 +130,0 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc