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

c2djs-helper

v0.2.3

Published

cocos2d-js helper.

Downloads

3

Readme

c2djs-helper

cocos2d-js helper. 与cocos2d-js项目配合使用。自动化读取指定目录(包括子目录)下的资源文件(指定后缀名筛选)然后生成resource.js文件。支持同名资源文件的自动重命名。

Getting Started

This plugin requires Grunt ~0.4.5

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install c2djs-helper --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('c2djs-helper');

The "c2djs_helper" task

Overview

In your project's Gruntfile, add a section named c2djs_helper to the data object passed into grunt.initConfig().

grunt.initConfig({
  c2djs_helper: {
    options: {
      // Task-specific options go here.
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
});

Options

options.sort

Type: Boolean Default value: false

用于决定是否开启排序功能,默认情况下不开启。开启排序后,不同子目录下的资源会添加相应的注释。

options.extension

Type: string Default value: *.png

指定需要读取的资源文件的扩展名,默认为png文件(*.png),如果需要指定多个扩展名,格式为{*.png,*.jpg,*.JPEG}

options.lazyLoadRegex

Type: RegExp Default value: ``

指定不需要预先加载的资源名称的正则表达式,会在相应的位置添加过滤代码,以阻止匹配的资源被预先加载。置空或非法的RegExp对象将使该功能无效,默认情况下值为空。

options.withTTF

Type: Boolean Default value: false

用于决定是否开启对TTF(字体)文件的支持。开启该选项,字体文件将会被载入,之后可以在cc.LabelTTF的调用中被使用。

Usage Examples

Default Options

默认选项将不会对资源文件进行排序。读取的资源文件也只有png一种。

grunt.initConfig({
  c2djs_helper: {
    options: {},
    files: {
      'dest/resource.js': ['res'],
    },
  },
});

Custom Options

自定义选项的例子里,sort选项开启了资源排序功能,开启排序后资源将根据目录及资源名称的升序进行排序。而extension选项指定了需要读取的资源文件的扩展名,这里指定的是读取png和jpg文件,最后lazyLoadRegex选项指示了那些不需要被预先加载的资源名称的匹配规则。

grunt.initConfig({
  c2djs_helper: {
    options: {
      sort: true,
      extension: '{*.png,*.jpg,*.JPEG}',
      lazyLoadRegex: /LazyLoadImg_[0-9]{0,}_jpg/,
      withTTF: true
    },
    files: {
      'dest/resource.js': ['res'],
    },
  },
});

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

v 0.1.0

  • 创建项目,实现基本功能。

v 0.1.2

  • 修复部分错误。

v 0.2.0

  • 新增非预加载资源过滤功能。

v 0.2.1

  • 修复部分错误。

v 0.2.2

  • 新增对文件名中-字符的处理。

v 0.2.3

  • 新增对ttf(字体)文件的支持。