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

lithe

v0.3.6

Published

a javascript common loader

Downloads

71

Readme

Lithe

Build Status 依赖模块状态

A browser-side script loader,compatible with the de facto standards(NodeJS/CommonJS). It's very simple and small,only 2.7kb gzipped.

If you use Gruntjs to build your project , you can use grunt-lithe

You can use bower manage modules Easier.

Chinese Documentation 中文文档


Installation

$ npm install lithe -g
$ git clone https://github.com/litheModule/lithe
$ cd lithe
$ npm install -d

command tools


$ lithe 

  Usage: lithe [options] [command]

  Commands:

    build <source> <target> build source to target
    compress <source> <target> compress source to target
    getpackage <source> <target> get source requires to target package

  Options:

    -h, --help           output usage information
    -V, --version        output the version number
    -c, --config <path>  set the config file,it will be return alias and basepath
    

public api for browser

define

//path/to/file.js
define('path/to/file',function(require,exports,module){
  var file = 'path/to/file.js';
  exports.filename = 'file.js';
  exports.filedir = 'path/to/';
  /**
   * module.exports = {
   *    filename:'file.js',
   *    filedir:'path/to'
   * };
   */
});

require

//path/to/app.js
define('path/to/app',function(require,exports,module){
  var file = require('path/to/file');
  console.log(file.filename); //file.js
  console.log(file.filedir) //path/to
  module.exports = 'i am app.js';
});

lithe.use

//anywhere
lithe.use('path/to/app',function(app){
    console.log(app); // i am app.js
});
//or
lithe.use('a.js','b.js',function(a,b){
  //a and b has required;
});

config

define('config',function(require,exports,module){
   module.exports = {
      //it will replace the real BASEPATH
      basepath:'http://localhost/debug/path', 
      //logogram
      alias:{
        'app':'path/to/app',
        'file':'path/to/file',
        //Relative directory proxy
        'UI':'../'
      }
   };
});

define('someOtherJs',function(){
  var app = require('app'),
  file = require('file');
});

public api for node

//npm install lithe
var lithe = require('lithe'),
tool = lithe.tool,
hfs = lithe.hfs,
options = tool.options;

options.basepath = 'your project base dir';
options.uglifyPath = 'your uglifyjs dir';
options.alias = {}; //your short alias config

tool.findJsAllrequires([filepath])

var requires = tool.findJsAllrequires('../app.js');
//app.js's requires are findout and alias will be replaced  

tool.concatFile([files],[target])

tool.concatFile(['/path/to/file1.js','/path/to/file2.js'],'/path/to/file1&file2.js');
//file1 and file2 will be merger

tool.uglifyJs([filepath],[target])

tool.uglifyJs('/path/to/file1&file2.js','path/to/file1&file2-min.js');
//Equivalent uglifyjs --reserved-names require -o path/to/file1&file2-min.js /path/to/file1&file2.js

hfs.cpdirSync([sourceDir],[targetDir])

hfs.cpdirSync('/path/to/dir1','/path/to/dir2');
//copy the folder by sync,if targetDir not exist it will be created.
//.git and .svn will be continue.

hfs.delSync([path])

hfs.delSync('/path/to/dir');
hfs.delSync('/path/to/file');
//del the folder or file sync
//.git and .svn will be continue.

hfs.mkdirSync([target])

hfs.mkdirSync('/path/dir')
//if the '/path' folder not exist,it will be created.

hfs.walk([path],[callback],[options])

hfs.walk('/path/',function(files){
    console.log(files); 'return path folder all js files';    
},{
    filter:function(file){
	  if (path.extname(el).indexOf('.js') > - 1) return true;
    }
});
//it's worked sync

hfs.writeFileSync([filepath],[data],[encoding = utf8])

hfs.writeFileSync('/path/file',"abcd");
//if path folder not exist,it will be created.

How to deploy in the web browser?

<script src="lithe.js"
        data-config="config.js"
        data-path="http://domain.com/"
        data-debug="true"
        data-main="app.js">
</script>

License

BSD license