-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into production
- Loading branch information
Showing
127 changed files
with
4,496 additions
and
6,259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,91 @@ | ||
# Toast UI CodeSnippet | ||
# TOAST UI CodeSnippet | ||
|
||
`tui-code-snippet` is group of utility methods to make ease with developing javascript applications. | ||
|
||
It includes several features like `class simulation`, `browser detecting`, `type checking` and +30 more. | ||
It includes several features like `class simulation`, `browser detecting`, `type checking` and more. | ||
|
||
`tui-code-snippet` supports IE8+ and modern browsers and already has been used for [open source javascript components](http://github.com/nhn/) and many commercial projects in [NHN](http://www.nhn.com) corporation. | ||
|
||
## Feature | ||
* browser.js | ||
* Browser detecting modules | ||
* collection.js | ||
* Modules to Process collecitons | ||
* Support util methods for collecitons | ||
* customEvent.js | ||
* Custom event modules | ||
* Add/Remove/fire custom events | ||
* defineClass.js | ||
* Defined classes module | ||
* enum.js | ||
* Const value modules | ||
* Making immutability values but IE8 low | ||
* func.js | ||
* Function modules | ||
* hashMap.js | ||
* Hash map modules | ||
* Managing data by key/value | ||
* inheritance.js | ||
* Simple inheritance modules (Nicholas C. Zakas, YUI Library) | ||
## Documents | ||
|
||
* [Getting Started](https://github.com/nhn/tui.code-snippet/blob/master/docs/getting-started.md) | ||
* [APIs](https://nhn.github.io/tui.code-snippet/latest/) | ||
* [v2.0 Migration Guide](https://github.com/nhn/tui.code-snippet/blob/master/docs/v2.0-migration-guide.md) | ||
|
||
## Features | ||
|
||
* array | ||
* Handle arrays | ||
* browser | ||
* Detect browser | ||
* collection | ||
* Process collections | ||
* Support util methods for collections | ||
* customEvents | ||
* Add/Remove/fire custom events | ||
* defineClass | ||
* Define classes | ||
* domEvent | ||
* Add, remove, fire DOM events | ||
* Control mouse events | ||
* domUtil | ||
* Control the information of DOM | ||
* Add, remove, find DOM class name | ||
* enum | ||
* Manage constant value | ||
* Make immutability values but IE8 low | ||
* formatDate | ||
* Format date strings | ||
* inheritance | ||
* Simple inheritance (Nicholas C. Zakas, YUI Library) | ||
* Call supur constructor of superclass | ||
* Have to get inheritance before define child | ||
* Using mixin and inner object | ||
* object.js | ||
* Object modules | ||
* Support utils to control object | ||
* string.js | ||
* String processing modules | ||
* Support utils such as decodeHTMLEntity, encodeHTMLEntity | ||
* type.js | ||
* Check data type | ||
* window.js | ||
* Window object modules | ||
* You need 'postDataBridgeUrl' options to avoid IE11 popup form submit bug. | ||
* Different domain have x-domain issue. | ||
* defineNamespace.js | ||
* Support utils to define namespace | ||
* formatDate.js | ||
* Formating date strings modules | ||
* defineModule.js | ||
* Support utils to define modules | ||
|
||
## Documentation | ||
* API: [https://nhn.github.io/tui.code-snippet/latest/](https://nhn.github.io/tui.code-snippet/latest/) | ||
* Tutorial: [https://github.com/nhn/fe.javascript/wiki/Toast-UI-CodeSnippet](https://github.com/nhn/fe.javascript/wiki/Toast-UI-CodeSnippet) | ||
|
||
## Tested Browsers | ||
* browser: | ||
* IE8 ~ IE11 | ||
* Edge | ||
* Chrome | ||
* Firefox | ||
* Safari | ||
|
||
## Usage | ||
### Use `npm` | ||
* Use mixin and inner object | ||
* object | ||
* Support utils to control object | ||
* request | ||
* Request image ping | ||
* string | ||
* Support utils such as decodeHTMLEntity, encodeHTMLEntity | ||
* tricks | ||
* Creates a debounced function and a throttled function | ||
* type | ||
* Check data type | ||
|
||
## Installation | ||
|
||
Install the latest version using `npm` command: | ||
|
||
``` | ||
$ npm install tui-code-snippet --save | ||
``` sh | ||
$ npm install --save tui-code-snippet | ||
``` | ||
|
||
or want to install the each version: | ||
or install the each version: | ||
|
||
``` | ||
$ npm install tui-code-snippet@<version> --save | ||
$ npm install --save tui-code-snippet@<version> | ||
``` | ||
|
||
To access as module format in your code: | ||
|
||
```javascript | ||
var util = require('tui-code-snippet'); | ||
``` | ||
## Usage | ||
|
||
### Use `bower` | ||
Install the latest version using `bower` command: | ||
Import only functions that you need in your code: | ||
|
||
``` | ||
$ bower install tui-code-snippet | ||
``` | ||
|
||
or want to install the each version: | ||
```javascript | ||
var func = require('tui-code-snippet/<folder>/<function>'); | ||
|
||
``` | ||
$ bower install tui-code-snippet#<tag> | ||
// for example, | ||
var inArray = require('tui-code-snippet/array/inArray'); | ||
var customEvents = require('tui-code-snippet/customEvents/customEvents'); | ||
``` | ||
|
||
To access as namespace format in your code: | ||
The folder structure can be found [here](https://github.com/nhn/tui.code-snippet/tree/production). | ||
|
||
```javascript | ||
var util = tui.util; | ||
``` | ||
## Browser Support | ||
|
||
### Download | ||
* [Download bundle files from `dist` folder](https://github.com/nhn/tui.code-snippet/tree/production/dist) | ||
* [Download all sources for each version](https://github.com/nhn/tui.code-snippet/releases) | ||
| <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 | | ||
| :---------: | :---------: | :---------: | :---------: | :---------: | | ||
| Yes | 8+ | Yes | Yes | Yes | | ||
|
||
## License | ||
[MIT LICENSE](https://github.com/nhn/tui.code-snippet/blob/master/LICENSE) | ||
|
||
This software is licensed under the [MIT](https://github.com/nhn/tui.code-snippet/blob/master/LICENSE) © [NHN](https://github.com/nhn). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* eslint-disable complexity */ | ||
/** | ||
* @fileoverview Returns the first index at which a given element can be found in the array. | ||
* @author NHN FE Development Lab <[email protected]> | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var isArray = require('../type/isArray'); | ||
|
||
/** | ||
* @module array | ||
*/ | ||
|
||
/** | ||
* Returns the first index at which a given element can be found in the array | ||
* from start index(default 0), or -1 if it is not present. | ||
* It compares searchElement to elements of the Array using strict equality | ||
* (the same method used by the ===, or triple-equals, operator). | ||
* @param {*} searchElement Element to locate in the array | ||
* @param {Array} array Array that will be traversed. | ||
* @param {number} startIndex Start index in array for searching (default 0) | ||
* @returns {number} the First index at which a given element, or -1 if it is not present | ||
* @memberof module:array | ||
* @example | ||
* var inArray = require('tui-code-snippet/array/inArray'); // node, commonjs | ||
* | ||
* var arr = ['one', 'two', 'three', 'four']; | ||
* var idx1 = inArray('one', arr, 3); // -1 | ||
* var idx2 = inArray('one', arr); // 0 | ||
*/ | ||
function inArray(searchElement, array, startIndex) { | ||
var i; | ||
var length; | ||
startIndex = startIndex || 0; | ||
|
||
if (!isArray(array)) { | ||
return -1; | ||
} | ||
|
||
if (Array.prototype.indexOf) { | ||
return Array.prototype.indexOf.call(array, searchElement, startIndex); | ||
} | ||
|
||
length = array.length; | ||
for (i = startIndex; startIndex >= 0 && i < length; i += 1) { | ||
if (array[i] === searchElement) { | ||
return i; | ||
} | ||
} | ||
|
||
return -1; | ||
} | ||
|
||
module.exports = inArray; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* @fileoverview Generate an integer Array containing an arithmetic progression. | ||
* @author NHN FE Development Lab <[email protected]> | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var isUndefined = require('../type/isUndefined'); | ||
|
||
/** | ||
* Generate an integer Array containing an arithmetic progression. | ||
* @param {number} start - start index | ||
* @param {number} stop - stop index | ||
* @param {number} step - next visit index = current index + step | ||
* @returns {Array} | ||
* @memberof module:array | ||
* @example | ||
* var range = require('tui-code-snippet/array/range'); // node, commonjs | ||
* | ||
* range(5); // [0, 1, 2, 3, 4] | ||
* range(1, 5); // [1,2,3,4] | ||
* range(2, 10, 2); // [2,4,6,8] | ||
* range(10, 2, -2); // [10,8,6,4] | ||
*/ | ||
function range(start, stop, step) { | ||
var arr = []; | ||
var flag; | ||
|
||
if (isUndefined(stop)) { | ||
stop = start || 0; | ||
start = 0; | ||
} | ||
|
||
step = step || 1; | ||
flag = step < 0 ? -1 : 1; | ||
stop *= flag; | ||
|
||
for (; start * flag < stop; start += step) { | ||
arr.push(start); | ||
} | ||
|
||
return arr; | ||
} | ||
|
||
module.exports = range; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* @fileoverview Zip together multiple lists into a single array. | ||
* @author NHN FE Development Lab <[email protected]> | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var forEach = require('../collection/forEach'); | ||
|
||
/** | ||
* Zip together multiple lists into a single array. | ||
* @param {...Array} ...Arrays - Arrays to be zipped | ||
* @returns {Array} | ||
* @memberof module:array | ||
* @example | ||
* var zip = require('tui-code-snippet/array/zip'); // node, commonjs | ||
* | ||
* var result = zip([1, 2, 3], ['a', 'b','c'], [true, false, true]); | ||
* console.log(result[0]); // [1, 'a', true] | ||
* console.log(result[1]); // [2, 'b', false] | ||
* console.log(result[2]); // [3, 'c', true] | ||
*/ | ||
function zip() { | ||
var arr2d = Array.prototype.slice.call(arguments); | ||
var result = []; | ||
|
||
forEach(arr2d, function(arr) { | ||
forEach(arr, function(value, index) { | ||
if (!result[index]) { | ||
result[index] = []; | ||
} | ||
result[index].push(value); | ||
}); | ||
}); | ||
|
||
return result; | ||
} | ||
|
||
module.exports = zip; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.