Skip to content

Commit fb0d71e

Browse files
committed
Merge branch 'master' into production
2 parents 2a459f7 + 47bccf7 commit fb0d71e

File tree

127 files changed

+4496
-6259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+4496
-6259
lines changed

.eslintrc.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ module.exports = {
44
"browser": true,
55
"amd": true,
66
"node": true,
7-
"jasmine": true,
8-
"jquery": true
7+
"jasmine": true
98
},
109
"globals": {
1110
"tui": true,
12-
"loadFixtures": true
11+
"fixture": true
1312
}
1413
};

README.md

Lines changed: 65 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,91 @@
1-
# Toast UI CodeSnippet
1+
# TOAST UI CodeSnippet
22

33
`tui-code-snippet` is group of utility methods to make ease with developing javascript applications.
44

5-
It includes several features like `class simulation`, `browser detecting`, `type checking` and +30 more.
5+
It includes several features like `class simulation`, `browser detecting`, `type checking` and more.
66

77
`tui-code-snippet` supports IE8+ and modern browsers and already has been used for [open source javascript components](https://github.com/nhn/) and many commercial projects in [NHN](http://www.nhn.com) corporation.
88

9-
## Feature
10-
* browser.js
11-
* Browser detecting modules
12-
* collection.js
13-
* Modules to Process collecitons
14-
* Support util methods for collecitons
15-
* customEvent.js
16-
* Custom event modules
17-
* Add/Remove/fire custom events
18-
* defineClass.js
19-
* Defined classes module
20-
* enum.js
21-
* Const value modules
22-
* Making immutability values but IE8 low
23-
* func.js
24-
* Function modules
25-
* hashMap.js
26-
* Hash map modules
27-
* Managing data by key/value
28-
* inheritance.js
29-
* Simple inheritance modules (Nicholas C. Zakas, YUI Library)
9+
## Documents
10+
11+
* [Getting Started](https://github.com/nhn/tui.code-snippet/blob/master/docs/getting-started.md)
12+
* [APIs](https://nhn.github.io/tui.code-snippet/latest/)
13+
* [v2.0 Migration Guide](https://github.com/nhn/tui.code-snippet/blob/master/docs/v2.0-migration-guide.md)
14+
15+
## Features
16+
17+
* array
18+
* Handle arrays
19+
* browser
20+
* Detect browser
21+
* collection
22+
* Process collections
23+
* Support util methods for collections
24+
* customEvents
25+
* Add/Remove/fire custom events
26+
* defineClass
27+
* Define classes
28+
* domEvent
29+
* Add, remove, fire DOM events
30+
* Control mouse events
31+
* domUtil
32+
* Control the information of DOM
33+
* Add, remove, find DOM class name
34+
* enum
35+
* Manage constant value
36+
* Make immutability values but IE8 low
37+
* formatDate
38+
* Format date strings
39+
* inheritance
40+
* Simple inheritance (Nicholas C. Zakas, YUI Library)
3041
* Call supur constructor of superclass
3142
* Have to get inheritance before define child
32-
* Using mixin and inner object
33-
* object.js
34-
* Object modules
35-
* Support utils to control object
36-
* string.js
37-
* String processing modules
38-
* Support utils such as decodeHTMLEntity, encodeHTMLEntity
39-
* type.js
40-
* Check data type
41-
* window.js
42-
* Window object modules
43-
* You need 'postDataBridgeUrl' options to avoid IE11 popup form submit bug.
44-
* Different domain have x-domain issue.
45-
* defineNamespace.js
46-
* Support utils to define namespace
47-
* formatDate.js
48-
* Formating date strings modules
49-
* defineModule.js
50-
* Support utils to define modules
51-
52-
## Documentation
53-
* API: [https://nhn.github.io/tui.code-snippet/latest/](https://nhn.github.io/tui.code-snippet/latest/)
54-
* Tutorial: [https://github.com/nhn/fe.javascript/wiki/Toast-UI-CodeSnippet](https://github.com/nhn/fe.javascript/wiki/Toast-UI-CodeSnippet)
55-
56-
## Tested Browsers
57-
* browser:
58-
* IE8 ~ IE11
59-
* Edge
60-
* Chrome
61-
* Firefox
62-
* Safari
63-
64-
## Usage
65-
### Use `npm`
43+
* Use mixin and inner object
44+
* object
45+
* Support utils to control object
46+
* request
47+
* Request image ping
48+
* string
49+
* Support utils such as decodeHTMLEntity, encodeHTMLEntity
50+
* tricks
51+
* Creates a debounced function and a throttled function
52+
* type
53+
* Check data type
54+
55+
## Installation
6656

6757
Install the latest version using `npm` command:
6858

69-
```
70-
$ npm install tui-code-snippet --save
59+
``` sh
60+
$ npm install --save tui-code-snippet
7161
```
7262

73-
or want to install the each version:
63+
or install the each version:
7464

7565
```
76-
$ npm install tui-code-snippet@<version> --save
66+
$ npm install --save tui-code-snippet@<version>
7767
```
7868

79-
To access as module format in your code:
80-
81-
```javascript
82-
var util = require('tui-code-snippet');
83-
```
69+
## Usage
8470

85-
### Use `bower`
86-
Install the latest version using `bower` command:
71+
Import only functions that you need in your code:
8772

88-
```
89-
$ bower install tui-code-snippet
90-
```
91-
92-
or want to install the each version:
73+
```javascript
74+
var func = require('tui-code-snippet/<folder>/<function>');
9375

94-
```
95-
$ bower install tui-code-snippet#<tag>
76+
// for example,
77+
var inArray = require('tui-code-snippet/array/inArray');
78+
var customEvents = require('tui-code-snippet/customEvents/customEvents');
9679
```
9780

98-
To access as namespace format in your code:
81+
The folder structure can be found [here](https://github.com/nhn/tui.code-snippet/tree/production).
9982

100-
```javascript
101-
var util = tui.util;
102-
```
83+
## Browser Support
10384

104-
### Download
105-
* [Download bundle files from `dist` folder](https://github.com/nhn/tui.code-snippet/tree/production/dist)
106-
* [Download all sources for each version](https://github.com/nhn/tui.code-snippet/releases)
85+
| <img src="https://user-images.githubusercontent.com/1215767/34348387-a2e64588-ea4d-11e7-8267-a43365103afe.png" alt="Chrome" width="16px" height="16px" /> Chrome | <img src="https://user-images.githubusercontent.com/1215767/34348590-250b3ca2-ea4f-11e7-9efb-da953359321f.png" alt="IE" width="16px" height="16px" /> Internet Explorer | <img src="https://user-images.githubusercontent.com/1215767/34348380-93e77ae8-ea4d-11e7-8696-9a989ddbbbf5.png" alt="Edge" width="16px" height="16px" /> Edge | <img src="https://user-images.githubusercontent.com/1215767/34348394-a981f892-ea4d-11e7-9156-d128d58386b9.png" alt="Safari" width="16px" height="16px" /> Safari | <img src="https://user-images.githubusercontent.com/1215767/34348383-9e7ed492-ea4d-11e7-910c-03b39d52f496.png" alt="Firefox" width="16px" height="16px" /> Firefox |
86+
| :---------: | :---------: | :---------: | :---------: | :---------: |
87+
| Yes | 8+ | Yes | Yes | Yes |
10788

10889
## License
109-
[MIT LICENSE](https://github.com/nhn/tui.code-snippet/blob/master/LICENSE)
90+
91+
This software is licensed under the [MIT](https://github.com/nhn/tui.code-snippet/blob/master/LICENSE) © [NHN](https://github.com/nhn).

array/inArray.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* eslint-disable complexity */
2+
/**
3+
* @fileoverview Returns the first index at which a given element can be found in the array.
4+
* @author NHN FE Development Lab <[email protected]>
5+
*/
6+
7+
'use strict';
8+
9+
var isArray = require('../type/isArray');
10+
11+
/**
12+
* @module array
13+
*/
14+
15+
/**
16+
* Returns the first index at which a given element can be found in the array
17+
* from start index(default 0), or -1 if it is not present.
18+
* It compares searchElement to elements of the Array using strict equality
19+
* (the same method used by the ===, or triple-equals, operator).
20+
* @param {*} searchElement Element to locate in the array
21+
* @param {Array} array Array that will be traversed.
22+
* @param {number} startIndex Start index in array for searching (default 0)
23+
* @returns {number} the First index at which a given element, or -1 if it is not present
24+
* @memberof module:array
25+
* @example
26+
* var inArray = require('tui-code-snippet/array/inArray'); // node, commonjs
27+
*
28+
* var arr = ['one', 'two', 'three', 'four'];
29+
* var idx1 = inArray('one', arr, 3); // -1
30+
* var idx2 = inArray('one', arr); // 0
31+
*/
32+
function inArray(searchElement, array, startIndex) {
33+
var i;
34+
var length;
35+
startIndex = startIndex || 0;
36+
37+
if (!isArray(array)) {
38+
return -1;
39+
}
40+
41+
if (Array.prototype.indexOf) {
42+
return Array.prototype.indexOf.call(array, searchElement, startIndex);
43+
}
44+
45+
length = array.length;
46+
for (i = startIndex; startIndex >= 0 && i < length; i += 1) {
47+
if (array[i] === searchElement) {
48+
return i;
49+
}
50+
}
51+
52+
return -1;
53+
}
54+
55+
module.exports = inArray;

array/range.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* @fileoverview Generate an integer Array containing an arithmetic progression.
3+
* @author NHN FE Development Lab <[email protected]>
4+
*/
5+
6+
'use strict';
7+
8+
var isUndefined = require('../type/isUndefined');
9+
10+
/**
11+
* Generate an integer Array containing an arithmetic progression.
12+
* @param {number} start - start index
13+
* @param {number} stop - stop index
14+
* @param {number} step - next visit index = current index + step
15+
* @returns {Array}
16+
* @memberof module:array
17+
* @example
18+
* var range = require('tui-code-snippet/array/range'); // node, commonjs
19+
*
20+
* range(5); // [0, 1, 2, 3, 4]
21+
* range(1, 5); // [1,2,3,4]
22+
* range(2, 10, 2); // [2,4,6,8]
23+
* range(10, 2, -2); // [10,8,6,4]
24+
*/
25+
function range(start, stop, step) {
26+
var arr = [];
27+
var flag;
28+
29+
if (isUndefined(stop)) {
30+
stop = start || 0;
31+
start = 0;
32+
}
33+
34+
step = step || 1;
35+
flag = step < 0 ? -1 : 1;
36+
stop *= flag;
37+
38+
for (; start * flag < stop; start += step) {
39+
arr.push(start);
40+
}
41+
42+
return arr;
43+
}
44+
45+
module.exports = range;

array/zip.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* @fileoverview Zip together multiple lists into a single array.
3+
* @author NHN FE Development Lab <[email protected]>
4+
*/
5+
6+
'use strict';
7+
8+
var forEach = require('../collection/forEach');
9+
10+
/**
11+
* Zip together multiple lists into a single array.
12+
* @param {...Array} ...Arrays - Arrays to be zipped
13+
* @returns {Array}
14+
* @memberof module:array
15+
* @example
16+
* var zip = require('tui-code-snippet/array/zip'); // node, commonjs
17+
*
18+
* var result = zip([1, 2, 3], ['a', 'b','c'], [true, false, true]);
19+
* console.log(result[0]); // [1, 'a', true]
20+
* console.log(result[1]); // [2, 'b', false]
21+
* console.log(result[2]); // [3, 'c', true]
22+
*/
23+
function zip() {
24+
var arr2d = Array.prototype.slice.call(arguments);
25+
var result = [];
26+
27+
forEach(arr2d, function(arr) {
28+
forEach(arr, function(value, index) {
29+
if (!result[index]) {
30+
result[index] = [];
31+
}
32+
result[index].push(value);
33+
});
34+
});
35+
36+
return result;
37+
}
38+
39+
module.exports = zip;

bower.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)