@pixfox/leechee-util

1.0.4 • Public • Published

Description

这个包集合一些常用工具方法,默认提供的是用于浏览器端的./dist/leechee.win.min.js,同时也提供了node环境下常用工具集./dist/leechee.node.min.js两者都实现了umd接口。 前者实现了UMD接口,后者则以commonjs2的方式提供接口。 leechee.win.min.js 支持现代浏览器以及ie9+。

虽供浏览器端使用,但没有对浏览器做版本和类别的兼容,所以不要直接以link方式引入来使用。换句话说请以模块编程方式来使用,结合打包工具如webpack,配合babel-loader之类的来做兼容处理。

The 'main' field of this package is './dist/leechee.win.min.js' for the default use in browsers, though 'leechee.node.min.js' can be useful in node environment. Both of these two files are accessible by 'umd' functions. The leechee.win.min.js enabled UMD interface, while leechee.node.min.js can be required as commonjs2 module.
leechee.win.min.js supports ie9+.

Don't link the leechee.win.js in html, though the target environment is browser, because it's not compatible with various browser versions or kernels. In other words, it works well as a module with bundle tool like webpack to make use of babel-loader.

Usage

link in HTML

    // link the source
    <script src="path/to/leechee.win.min.js"></script>  
    // leechee would be a global variable of window
    <script>
        leechee.ready(function(){
            console.log(leechee.env);
            leechee.on(leechee.rooter(),'click',function(e){
                document.querySelector('body').style.backgroundColor = 'red'
            })
        })
    </script>

install in Node

    npm install @pixfox/leechee-util

in bussiness code (By default leechee.win.min.js is the main module )

import * as customName from '@pixfox/leechee-util' // as es6 module   
import {v,ready} from '@pixfox/leechee-util' // as es6 module   
const leechee = require( '@pixfox/leechee-util') // as commonjs module   
const {v,env} = require( '@pixfox/leechee-util') // as commonjs module 

treeshaking in webpack

import {v,ready} from '@pixfox/leechee-util'/src/win    // for brower env
import {v,env} from '@pixfox/leechee-util'/src/node    // for node env

Note:'Treeshaking' works with es6 module pattern in 'production' mode of webpack and , so you may get some errors like 'Unrecognized identifier' in non-morden browers in 'development' mode of webpack

Readme

Keywords

Package Sidebar

Install

npm i @pixfox/leechee-util

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

33.4 kB

Total Files

14

Last publish

Collaborators

  • pixfox