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

coding

v0.0.2

Published

分析单个 Node 文件,解析其依赖,并将依赖及原文件合并成一个与 Node 无关的文件

Downloads

14

Readme

coding

NPM version Build Status Dependency Status Code Climate Coverage Status

分析单个 Node 文件,解析其依赖,并将依赖及原文件合并成一个与 Node 无关的文件

因为它们编译出的文件很丑,而且添加了很多多余的代码。

  • coding 有什么特点?

缺点:

  • 需要遵守一定的格式来编写模块,也就是说开源的模块大部分都不适用,所以 coding 适合组织自己的代码,就像 jquery 一样
  • 每个模块即一个变量,会导入到全局之中,所以模块之间需要避免重名,但是支持设置 global,设置了的话所有变量会导入到 global

为什么还要用它:

  • 编译后的文件相对来说好看些
  • 当你有几个文件都需要引用同一个模块时,同时这几个文件并不只针对 Node,还需要针对 Browsers 也起作用
  • 可以组织自己的一个模块库,方便引用
  • 测试也方便,可以分小模块测试

安装

$ npm install --save coding

or

$ npm install --global coding

模块编写风格

  • requiremoduleexports 不能被重新定义,也不能创建它们的别名
  • 不支持 require('foo').bar 的写法
  • module.exports 应该写在最外层
  • require("xxx") 函数中只支持字面量的字符串,不能包含变量,也不能包含任何的表达式

使用

In javascript:

var coding = require('coding');
coding(filePath, options); // return compiled file content

When installed in global

coding [options] <file> // Use coding --help to see more helps

options

global

Type: string, Default: 'G'

模块变量的命名空间

rename

Type: function, Default: null

根据模块的文件路径重命名模块

函数的参数为模块对应的路径,如果函数返回的不为字符串,则使用系统默认的模块名称

addFilePathComment

Type: boolean, Default: true

在合并后的文件中添加文件路径的注释

saveMainExport

Type: boolean, Default: false

是否保留主文件中的 exports 声明

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 gulp.

Reference

License

Copyright (c) 2015 Zhonglei Qiu. Licensed under the MIT license.