Jextend
常用的一些javascript函数总结
Status
代码 已经打包发布到 RubyGems.
Installation
Add this line to your application's Gemfile:
gem 'jextend'
And then execute:
$ bundle
Or install it yourself as:
$ gem install jextend
Write this in your application.js
//=require jextend
Usage
Array
[2,3,5].contains(3);
//=>true
[2,3,5].contains(6);
//=>false
Date
new Date().format('yyyy-MM-dd');
//=>"2016-04-20"
Math
Math.n_pow(2,3);
//=>8_
Math.decimal_point('3.3333',2);
//=>3.33_
String
"Good {0} everyone.How do {1} do?".format('morning','you');
//=> "Good morning everyone.How do you do?"
String.random(32);
//=>"t7m5dzu3zn2jxb34qykjkrifjeo77rj1"
String.random(10,true);
//=>"f0jz19hgER"
window.location.params
//current_url: http://localhost:3000/?start_date=2015-12-06&type=newer_
window.location.params()
//=>{start_date:'2015-12-06',type:'newer'}
Contributing
- Fork it ( https://github.com/[my-github-username]/jextend/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
