strman是无任何依赖的string操作库,前后端通用
A Javascript string manipulation library without npm dependences.
安装
npm install strman --save
bower install strman
用法
With ES6/import
import{slugify}from'strman';let title ="A Javascript string manipulation library.";let result = slugify(title);// result => "a-javascript-string-manipulation-library"
With require
var slugify =require('strman').slugify;let title ="A Javascript string manipulation library.";let result = slugify(title);// result => "a-javascript-string-manipulation-library"
With Browser
scriptsrc="./bower_components/strman/dist/strman.js"> var result = _s.isString('strman'); // result => true
Also available for AMD
API
说明
npm依赖分2种,常规依赖和dev依赖。
strman没有任何常规依赖,也就是它自己说的:“without npm dependences”,但它是es 6语法,借助babel开发的,这是开发阶段使用的依赖
看一下它的package.json
"main":"dist/strman.js",
dist是压缩后的目录,也就是说它的模块主文件是压缩后的。
根目录里有一个gulpfile.babel.js用于压缩混淆,这就很明显了
gulp.task('browserify',()=>{ browserify({ entries:'./src/strman.js', transform:[babelify, es6ify, deglobalify],// Generate a UMD bundle for the supplied export name.// This bundle works with other module systems and sets the name// given as a window global if no module system is found. standalone:'_s',// Enable source maps that allow you to debug your files// separately. debug:true}).bundle().pipe(source('strman.js')).pipe(buffer()).pipe(uglify()).pipe(gulp.dest('dist')).pipe(gulp.dest('public'));});
总结
目前看是基于mocha和chai的测试,基本ok,集成了travis-ci,但无测试覆盖率,无benchmark,性能如何还不好说
从开源到今天(4月24日),才12天,已经754个star,还算是不错的了,想参与的可以去贡献一下。另外要说的是它是学习es6的非常好的范例,推荐。
全文完
欢迎关注我的公众号【node全栈】
如果想参与评论,请点击原文链接,进入国内最专业的cnode论坛