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

sr-cos

v1.0.2

Published

写数据到特定的cos目录中

Downloads

9

Readme

sr-cos

带有缓存的的存储数据到cos目录上,默认缓存大于5M或距离上次缓存达到3分钟(任意一个条件满足)则写一次cos

Installation

npm install sr-cos --save

Usage


 /**
  * 环境变量:COS_INTERVAL可以控制该cos缓存发送的时间,单位是分钟
  * 例如: COS_INTERVAL = 1 ,表示每1分钟刷新一次缓存
  *       COS_INTERVAL = 3 ,表示每3分钟刷新一次缓存
  * /

/**
 * 唯一必填的参数
 * @param {*} cosPath 写cos的路径地址,格式:cosn://srdc-1257214331/dataset_test
 * 
 * @param {*} secretId cos的密钥Id,默认从环境变量SECRET_ID
 * @param {*} secretKey cos的密钥Key,默认为环境变量SECRET_KEY
 * @param {*} cosRegion cos路径所属的地区,默认:ap-guangzhou
 * @param {*} cosPartition 分区类型:year, month, day,默认为day
 * @param {*} isCache 是否开启缓存,默认为true
 * @param {*} thresholdSize 最久上报缓存大小,单位秒,默认5M
 * @param {*} logging 日志函数
 */
const srcos = new SRCos({
  cosPath: 'cosn://base-bucket/default/result/',

  srId: process.env.SECRET_ID,
  srSecret: process.env.SECRET_KEY,
  cosRegion = 'ap-guangzhou',
  cosPartition = 'day',
  isCache = true,
  thresholdSize = 5 * 1024 * 1024,
  logging: (data) => { console.log(data); },
});

srcos.write('data').then((data) => {
  // 写入成功
  if (data) {
    console.log(data);
    return;
  }
  // 写入失败
  console.log(data);
});