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 🙏

© 2026 – Pkg Stats / Ryan Hefner

jsreward

v1.2.5

Published

A library for game written by javascript to deal with reward simple both server and client;

Readme

jsreward

约定


  • 为了配置和显示处理简单,使用物品字符串表示东西的类型,id,数量等。

  • 金币-1,钻石-2,精力-3,星星-4,道具-5,角色-6,碎片-7,碟片-8,礼包-9

  • 形式为:"type|param1|param2",如下

      1|1000--金币1000
      2|1000--钻石1000个
      3|10  --精力10点
      4|6   --星星6个
      5|1|2 -- id为1的道具两个
      6|2   -- id为2的角色
      7|1|9 -- id为1的碟片的第9个碎片
      8|1   -- id为1的碟片
      9|百度|https://www.baidu.com/img/bd_logo1.png -- 名字为百度的物品
  • 策划填写

      1|1000,5|1|1,7|1|9
  • 概率掉落,最后一个可选字段表示概率

      1|1000,5|1|1,7|1|9|20 -- 金币1000,id为1的道具1个,20%几率掉落碎片1,9
  • 多个物品中随机一个

      1|1000,5|1|1,[7|1|9|20-7|1|8|20]
      -- 金币1000,id为1的道具1个,50%几率掉落碎片1,9,50%几率掉落碎片1,8,20表示权重
        
        

功能

  1. 奖励策划填写,服务端,客户端统一
  2. obj,收益表达字符 互转
  3. 多个同种奖励自动合并
  4. 几率奖励掉落奖励

使用


  1. 安装

     npm install jsreward
    	
  2. 编码

     var reward = require("jsreward");
        
     reward.addType(1, 'coin', 'num');
     reward.addType(3, 'diamond', 'num');
     reward.addType(5, '道具', 'id', 'num');
     reward.addType(7, '碎片', 'id', 'index');
     reward.addType(9, '其他', 'name', 'url');
    
     reward.setCountName('num');
    
     var rewardStr = '1|1000,5|1|1, 1|1500,5|1|1,[7|1|9|20-7|1|8|20]';
     var rewards = reward.parseReward(rewardStr);
    
     // reward->str
     var mstr = reward.rewardToStr(rewards);
    
     console.log(mstr);
    
     //reward->str->reward->json
     var newRewardStr = JSON.stringify(reward.parseReward(mstr));
    
     should.equal(newRewardStr, JSON.stringify(rewards));