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

cordova-file-cache

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-file-cache - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

dist/CordovaFileCache.js

4

bower.json
{
"name": "cordova-file-cache",
"main": "CordovaFileCache.js",
"version": "0.1.1",
"main": "dist/CordovaFileCache.js",
"version": "0.2.0",
"homepage": "https://github.com/markmarijnissen/cordova-file-cache",

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

var hash = require('./murmerhash');
var Promise = null;
/* Cordova File Cache x */
function FileCache(options){

@@ -16,10 +17,13 @@ // cordova-promise-fs

this._mirrorMode = options.mode !== 'hash';
this._retry = options.retry || [500,1500,8000];
// normalize path
this._localRoot = options.localRoot || 'data';
this._serverRoot = options.serverRoot || '';
if(this._localRoot[this._localRoot.length -1] !== '/') this._localRoot += '/';
if(this._localRoot[0] !== '/') this._localRoot = '/' + this._localRoot;
if(this._serverRoot && this._serverRoot[this._serverRoot.length -1] !== '/') this._serverRoot += '/';
this._serverRoot = options.serverRoot || '';
if(!!this._serverRoot && this._serverRoot[this._serverRoot.length-1] !== '/') this._serverRoot += '/';
if(this._serverRoot === './') this._serverRoot = '';
// set internal variables

@@ -51,3 +55,5 @@ this._downloading = []; // download promises

resolve(entries);
},reject);
},function(){
resolve([]);
});
});

@@ -60,4 +66,5 @@ };

urls.forEach(function(url){
url = self.toServerURL(url);
if(self._added.indexOf(url) === -1) {
self._added.push(self.toServerURL(url));
self._added.push(url);
}

@@ -77,3 +84,2 @@ });

promises.push(self._fs.remove(path));
console.log('deleting',path);
delete self._cached[path];

@@ -117,3 +123,3 @@ });

}
// keep track of number of downloads!

@@ -137,3 +143,2 @@ var queue = self.getDownloadQueue();

index++;
console.log('done',index,total);
// when we're done

@@ -158,4 +163,3 @@ if(index !== total) {

queue.forEach(function(url,index){
console.log('download',url,self.toPath(url));
var download = fs.download(url,self.toPath(url),onSingleDownloadProgress);
var download = fs.download(url,self.toPath(url),{retry:self._retry},onSingleDownloadProgress);
download.then(onDone,onDone);

@@ -206,3 +210,3 @@ self._downloading.push(download);

FileCache.prototype.toServerURL = function toServerURL(path){
return path.substr(0,4) !== 'http'? this._serverRoot + path: path;
return path.indexOf('://') < 0? this._serverRoot + path: path;
};

@@ -224,7 +228,3 @@

} else {
if(url.substr(0,4) !== 'http') {
throw new Error('Invalid url. Must start with "http".');
} else {
return this._localRoot + hash(url) + url.substr(url.lastIndexOf('.'));
}
return this._localRoot + hash(url) + url.substr(url.lastIndexOf('.'));
}

@@ -231,0 +231,0 @@ };

{
"name": "cordova-file-cache",
"version": "0.1.1",
"version": "0.2.0",
"description": "Cordova File Cache",
"main": "index.js",
"scripts": {
"prepublish": "gluejs --include index.js --include murmerhash.js --global CordovaFileCache > CordovaFileCache.js",
"prepublish": "webpack index.js dist/CordovaFileCache.js --output-library CordovaFileCache --output-library-target var",
"test": "echo \"Error: no test specified\" && exit 1"

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

@@ -13,7 +13,5 @@ cordova-file-cache

npm install cordova-file-cache cordova-promise-fs
# or just download and include the javascript
curl https://raw.githubusercontent.com/markmarijnissen/cordova-promise-fs/master/CordovaPromiseFS.js
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 +21,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) and [CordovaFileCache.js](https://raw.githubusercontent.com/markmarijnissen/cordova-file-cache/master/dist/CordovaFileCache.js)
## Usage

@@ -117,2 +119,7 @@

### 0.2.0 (07/11/2014)
* Many small bugfixes
* Upgraded the build process with `webpack`
### 0.1.0 (06/11/2014)

@@ -124,3 +131,3 @@

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

@@ -127,0 +134,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