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

pc-require

v0.0.6

Published

js module loader for browser with fis3/pcat/fis3-postpackager-autocombo

Downloads

3

Readme

Package Control Messages

#pc-require.js

#API

##define('name',function(require,exports,module){})

###说明 定义模块,define('模块名',function 模块函数(require,exports,module){})

  • 模块函数只会在 require('模块名') 的时候才会被执行,且多次 require 只会执行一次。
  • 模块函数里的require用法跟全局的require的用法一样,需要什么模块就 require 什么模块。
  • 模块函数里的exportsmoduleNode.js的用法和概念是一样的。

###例子

define('a',function(require,exports,module){
  a.name = 'a'
})

##require('name')

###说明 加载同步模块,针对已经被define的模块才能进行require调用

###例子

var a = require('a')
console.log(a.name)

##require.config(config)

###说明 异步模块配置接口。

{
  domain: 'http://www.pc.com',
  path: {
    'jQuery': '/static/jQuery.min.js', //key => 模块名,value => 模块路径(相对于 domain 或者 相对于当前页面地址)
    'temp': '/static/temp.min.js',
    'slide': '/static/slide.min.js'
  },  
  deps: {
    'slide' : ['jQuery','temp'] //模块的依赖,依赖里面填入模块名。
  },
  combo: false, //是否使用 combo url
  comboUrl: '/??' //用于连接combo和域名参数。如:/?? => http://www.pc.com/??/static/jQuery.min.js,/static/temp.min.js,/static/slide.min.js。 不适用 combo 是该参数无效。
}

##require.async(['a','b'])

###说明 require.async(['模块名A','模块名B','模块名C']).then(回调函数)

加载异步模块,或者直接加载js文件、css文件。

  • 加载异步模块的时候需要进行配置。
  • 如果在配置里面未找到对应模块名,将会当做url进行资源加载。
  • 返回一个Promise风格的对象,但并非是ES2015Promise对象。
  • 只需要在配置里配置好依赖关系,就会自动加载这些模块所需要的所有依赖模块。
  • 目前参数只支持数组。

###示例

require
  .async(['slide','a'])
  .then(function(slide,a){ //模块会变成参数注入进来。
    slide.init()
    console.log(a.name)
  })