jextend 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +49 -6
- data/lib/jextend/version.rb +1 -1
- data/vendor/assets/javascripts/jextend/string.js +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a93324b3e5f1dedf5c78f1a1620244768e75d70c
|
4
|
+
data.tar.gz: c63d128d90d2f86218079ff2878f38ed6223ad0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88df0309d3a927a3372e29fccc70ae99a3da8f966177c4cd11125f3e6d7633ccce1563c5f8c8120f6410361575f8de3e4005aacf07ee13092ebaa81dc99810e6
|
7
|
+
data.tar.gz: 00ffb2816643cde1511832619a6937ecbc59919c6e59dc611eb11bea0eb379c7d8d58f004f658640d882ed48cb97dd48a9a730e99de23bb492e8530cddede13c
|
data/README.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
# Jextend
|
2
2
|
|
3
|
-
|
3
|
+
常用的一些javascript函数总结
|
4
4
|
|
5
|
-
|
5
|
+
|
6
|
+
## Status
|
7
|
+
代码 已经打包发布到 RubyGems.
|
8
|
+
|
9
|
+
[![image](https://ruby-china-files.b0.upaiyun.com/photo/5982eaaa64f467d9dbda03ad4f40ea27.png)](https://rubygems.org/gems/jextend)
|
6
10
|
|
7
11
|
## Installation
|
8
12
|
|
@@ -20,15 +24,54 @@ Or install it yourself as:
|
|
20
24
|
|
21
25
|
$ gem install jextend
|
22
26
|
|
27
|
+
Write this in your `application.js`
|
28
|
+
```javascript
|
29
|
+
//=require jextend
|
30
|
+
```
|
31
|
+
|
23
32
|
## Usage
|
33
|
+
### Array
|
24
34
|
|
25
|
-
|
35
|
+
```javascript
|
36
|
+
[2,3,5].contains(3);
|
37
|
+
//=>true
|
38
|
+
[2,3,5].contains(6);
|
39
|
+
//=>false
|
40
|
+
```
|
41
|
+
### Date
|
26
42
|
|
27
|
-
|
43
|
+
```javascript
|
44
|
+
new Date().format('yyyy-MM-dd');
|
45
|
+
//=>"2016-04-20"
|
46
|
+
```
|
47
|
+
### Math
|
48
|
+
```javascript
|
49
|
+
Math.n_pow(2,3);
|
50
|
+
//=>8_
|
51
|
+
Math.decimal_point('3.3333',2);
|
52
|
+
//=>3.33_
|
53
|
+
```
|
54
|
+
### String
|
28
55
|
|
29
|
-
|
56
|
+
```javascript
|
57
|
+
"Good {0} everyone.How do {1} do?".format('morning','you');
|
58
|
+
//=> "Good morning everyone.How do you do?"
|
59
|
+
|
60
|
+
String.random(32);
|
61
|
+
//=>"t7m5dzu3zn2jxb34qykjkrifjeo77rj1"
|
62
|
+
|
63
|
+
String.random(10,true);
|
64
|
+
//=>"f0jz19hgER"
|
65
|
+
|
66
|
+
```
|
67
|
+
|
68
|
+
### window.location.params
|
69
|
+
```javascript
|
70
|
+
//current_url: http://localhost:3000/?start_date=2015-12-06&type=newer_
|
71
|
+
window.location.params()
|
72
|
+
//=>{start_date:'2015-12-06',type:'newer'}
|
73
|
+
```
|
30
74
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
75
|
|
33
76
|
## Contributing
|
34
77
|
|
data/lib/jextend/version.rb
CHANGED
@@ -20,3 +20,19 @@ String.prototype.format = function (args) {
|
|
20
20
|
}
|
21
21
|
return result;
|
22
22
|
};
|
23
|
+
|
24
|
+
/**
|
25
|
+
* 生成随机字符串
|
26
|
+
* @param len 字符串长度
|
27
|
+
* @param includeUpcase 是否包含大写字符,默认为false
|
28
|
+
* @returns {string}
|
29
|
+
*/
|
30
|
+
String.random = function (len, includeUpcase) {
|
31
|
+
var str = '0123456789abcdefghijklmnopqrstuvwxyz';
|
32
|
+
var randomStr = '';
|
33
|
+
for (var i = 0; i < len; i++) {
|
34
|
+
var c = String(str[parseInt(Math.random() * str.length)]);
|
35
|
+
randomStr += (includeUpcase && parseInt(Math.random() * 10) % 2 == 0) ? c.toUpperCase() : c;
|
36
|
+
}
|
37
|
+
return randomStr;
|
38
|
+
};
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jextend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- saxer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|