npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-file-cache

v1.0.12

Published

file cache module

Downloads

2

Readme

文件缓存模块

依赖以下包

  • react-native-requests
  • react-native-omfs
  • react-native-sqlite-storage

必须在项目显示安装以上依赖包,否则react-native link命令无法链接到工程。

安装说明

npm install react-native-filecache --save

使用说明

模块对外导出两部分:FileCache级FileType.

FileCache一共四个方法:

  • fetch 获取uri缓存,如果不存在则自动下载到缓存。
  • save 保存本地文件到缓存
  • remove 删除缓存
  • clear 清空缓存

以上方法使用说明参见filecache.js源文件中的注释。

FileType定义了内置的文件类型:

  • Image 图片
  • Video 视频
  • Audio 音频
  • Voice 语音
  • Other 其他

以上类型都为字符串。

####fetch使用示例如下:

import { FileCache,FileType,CacheImage } from 'react-native-file-cache';

//定义fetch option
let option = {
		//定义下载进度
        onProgress: (received, total) => {
            console.log('FileCache progress', received, total);
        },
        //扩展名
        ext:'png',
        type: FileType.Image
    };
    
//获取缓存
let fetchTask = FileCache.fetch('http://www.baidu.com/', option);
fetchTask.then((path) => {
        console.log('FileCacheManager,done 1', path);
    })
    .catch((error) => {
        console.log('FileCacheManager,error 1', error);
    });

.
.
.

//取消获取缓存操作
fetchTask.cancel();

//CacheImage为自定义组件,用于为网络图片增加缓存
    

####save使用示例如下:

import { FileCache,FileType } from 'react-native-filecache';

FileCache.save(
	'http://www.baidu.com',
	'/Users/lcg/data/image/1.png',
	{ type: FileType.Other,ext: 'png'})
	.then((path) => {
		console.log('FileCacheManager,done 6',path);
	})
	.catch((error) => {
		console.log('FileCacheManager,error 6',error);
	});