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

tframe-rights

v8.0.9

Published

System right management subset of tFrame

Downloads

2

Readme

tframe-rights

System right management subset of tFrame

tFrame 平台的 权限处理子集

使用范例:

  • 实例定义

    可以用种子数组或键值对象直接初始化实例

	let Tright = require('preRight);
  
  // 用键值对象初始化实例
  let seedObj = {
    add: '新增',
    edit: '编辑',
    del: '删除'
  };
  let currRight1 = new Tright(seedObj);

  // 用tframe-enum代替键值对象初始化实例
  let tEnum = require('tframe-enum');
  let seedEnum = tEnum.sys.seed.crud;
  let currRight2 = new Tright(seedEnum);
  • 获取实例权限定义的枚举

console.log(currRight1.getDefine());
// {
  add: 1,
  edit: 2,
  del: 4
}
  • 获取完整的实例键集合

console.log(currRight1.getKeys());
// ['add', 'edit', 'del']
  • 获取完整的实例标签集合

console.log(currRight1.getTitles());
// ['新增', '编辑', '删除']
  • 获取实例的默认初始值(所有权限均为否)

console.log(currRight1.getDefaultVal());
// [0, 0, 0]

// 通过传入的用户权限值,生成值序列 // @val:权限值

let val = 6;
console.log(currRight1.getValList(val));
// [0, 1, 1]

// 通过传入的用户权限值,生成有效 key 或 title 序列 // @val:权限值 // @asTitle:获取 key 还是 title,默认为 flase(输出key)

let val = 6;
console.log(currRight1.getKeyList(val));
// ['edit', 'del']
console.log(currRight1.getKeyList(val, true));
// ['编辑', '删除']

// 根据传入的权限项(s),返回用户授权值 // @rtItem:要设置的用户权限项(限于类初始化时提供的项列表)(不定参数项,或数组)

console.log(createValue('add', 'del'));
// 返回:5
console.log(createValue(['add', 'del']));
// 返回:5
let val = {
  add: Foo,
  del: Bar
};
console.log(createValue(val));
// 返回:5
  • 初始化

/* 分类初始化权限实例
**  @bizArr:业务授权种子,要求如下:
            1、必须为普通键值对象(不包括 Map\WeakMap)
    参数示例: [{
                code: foo,
                seedCode: 'foo1,foo2,foo3',
                seedTitle: 'foo标题1,foo标题2,foo标题3'
              }, {
                code: foo,
                seedCode: 'foo1,foo2,foo3',
                seedTitle: 'foo标题1,foo标题2,foo标题3'
              }]
    输出示例: {
      // 源于 tframe-enum.sys.seed.crud 的权限集合
      crud: {
        handler: foo       // 代表通用的CRUD权限集合
        note: { 
          read: 查看
          foo...
        }
      },
      // 源于 tframe-enum.sys.seed.extend 的权限集合
      extend: {
        handler: bar        // 代表通用的扩展功能权限集合
        note: {
          import: 导入
          foo...
        }
      },
      // 源于传入参数所定义的业务权限集合
      biz: {
        bizFoo: {
          handler: bizFooHandler      // 代表 bizFoo 业务所具备的权限集合
          note: {
            ex1: 发出,
            ex2: 收到
          }
        },
        bizBar: {
          handler: bizBarHandler      // 代表 bizBar 业务所具备的权限集合
          note: {
            ex1: 入库,
            ex2: 验收
          }
        }
      }
    }
*/
  • 调用

    初始化后,可以直接调用每个 handler的 实例方法。


5. 版本变更记录