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

fashop-policy

v1.0.9

Published

policy.js

Downloads

3

Readme

policy.js

js验证policy语法

php版本 : https://github.com/hanwenbo/policy

本库主要用于FaShop项目内使用,不建议其他人直接使用

安装

npm install fashop-policy --save

引入和使用

import Policy from "fashop-policy"

var policy =  new Policy
// 支持添加多组
policy.addPolicy({"Statement": [{"Action": ["user/*","goods/info"], "Effect": "Allow"}]})
policy.addPolicy({"Statement": [{"Action": ["user/*","goods/list"], "Effect": "Deny"}]})

if(policy.verify('goods/info') === true){
    // 有权限...
    // 执行.........
}else{
    // 不显示菜单
    // 或者显示占位信息
}

// 测试
policy.verify('goods/info').should.be.equal(true)
policy.verify('goods/list').should.be.equal(false)

// 验证表现层,用于多个权限同时验证,当都满足条件时才显示某个节点
let string  = '(( goods/*  && !goods/list) && goods/info  && goods/info && goods/infoXx) || * || goods/info';

policy.viewVerify(string)

更便捷的语句式操作,请见github的fashop-admin项目

测试

自动执行test目录下的所有文件

mocha

发布

npm login --registry https://registry.npmjs.org
npm publish --registry https://registry.npmjs.org

发布的时候注意源

源管理工具:NRM

安装 sudo npm install -g nrm

查看源列表 nrm ls

使用某个源 nrm use npm

开发

  • 编译基于rollup
  • 支持浏览器和nodejs

疑问

由于不熟悉js

不明白为什么class不能定义属性如:

class XX{
    name;
    sex;
}

在umi.js下就可以

但在rollup下编译就过不去,需要通过构造函数去this.xxxx赋值

如果谁知道,请告诉我

class了解参考:http://es6.ruanyifeng.com/#docs/class

感谢

img img