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

@fekit/mc-cookie

v2.1.5

Published

一个操作cookie的常用方法。可以对cookie进行增删改查工作,并且可以单条或者批量操作。

Downloads

3

Readme

MC-COOKIE

一个操作 cookie 的常用方法。可以对 cookie 进行增删改查工作,并且可以单条或者批量操作。

索引

演示

http://fekit.cn/plugins/mc-cookie/

开始

NPM:

npm i @fekit/mc-cookie

CDN:

<script type="text/javascript" src="https://cdn.fekit.cn/@fekit/mc-cookie/mc-cookie.umd.min.js"></script>
<script>
  cookie.set({ key: 'aaa', val: 111 });
</script>

传参

{
    key   : 'aaa',                           // 属性名
    val   : 'this is aaa; ',                 // 属性值
    domain: '',                              // 域名(默认不设为当前页面域名,一般不用设置)
    path  : '',                              // 域名下子路经(默认不设,一般不用设置)
    time  : '+{1y1m11d1h1n1s}'               // + 在现在开始算起的y年m月d日h时n分s秒后失效, 可以仅设置其中一个,比如1d=1天后失效
            '2022-12-12 10:0:0'              // 以字符串形式传入指定时间
            1665367200000                    // 转入时间戳
            new Date('2022-12-22 10:0:0')    // 直接传时间对象
}

示例

设置一个属性:

// 引入插件文件,后面的示例略过
import cookie from '@fekit/mc-cookie';
cookie.set({
  key: 'aaa',
  val: 'aaa_111$222#333@444%555*666',
});

设置多个属性:

cookie.set([
  {
    key: 'bbb',
    val: 'bbb_abc+123+中文+〜!#¥%……&*()',
    time: '+{1d}', // 1天后失效
  },
  {
    key: 'ccc',
    val: 'ccc_abc+123+中文+〜!#¥%……&*()',
    time: '+{2d5h30m}', // 2天5小时30分钟后失效
  },
  {
    key: 'ddd',
    val: 'ddd_abc+123+中文+〜!#¥%……&*()',
    time: '2022-12-12', // 在2022年12月12日0点0分0秒失败
  },
]);

获取一个属性:

let aaa = cookie.get('aaa');
console.log(aaa);

以数组形式获取多个属性:

let aList = cookie.get(['aaa', 'bbb', 'ccc']);
console.log(aList);

以对象形式获取多个属性:

let oList = cookie.get({ a: 'aaa', keyName: 'bbb', abc: 'ccc' });
console.log(oList);

获取全部属性并返回数组:

let all = cookie.all();
console.log(all);

另外一种方便灵活的用法:

let all = cookie.all();

// 我想获取aaa
console.log(all.aaa);
// 还需获取ccc
console.log(all.ccc);

删除一个属性:

cookie.del('aaa');

删除多个属性:

cookie.del(['aaa', 'bbb', 'ccc']);

删除全部属性:

cookie.del('*');

判断是否有某个属性:

let hasAAA = cookie.has('aaa');
console.log(hasAAA);

版本

v2.1.1 [Latest version]
1. 优化time设置失效时间的入参,添加多种入参方式
v2.0.9
1. 修复package.json配置错误
v2.0.8
1. 修改了打包工具
2. 提供了esm和umd两种方式

反馈

如果您在使用中遇到问题,请通过以下方式联系我。
QQ: 860065202
EMAIL: [email protected]