]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/pretty-json/node_modules/jsonminify/docs/minify.json.js.html
Remove powerline config
[rbdr/dotfiles] / atom / packages / pretty-json / node_modules / jsonminify / docs / minify.json.js.html
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="utf-8">
5 <title>JSDoc: Source: minify.json.js</title>
6
7 <script src="scripts/prettify/prettify.js"> </script>
8 <script src="scripts/prettify/lang-css.js"> </script>
9 <!--[if lt IE 9]>
10 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11 <![endif]-->
12 <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13 <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14 </head>
15
16 <body>
17
18 <div id="main">
19
20 <h1 class="page-title">Source: minify.json.js</h1>
21
22
23
24
25
26 <section>
27 <article>
28 <pre class="prettyprint source"><code>/*! JSON.minify()
29 v0.1 (c) Kyle Simpson
30 MIT License
31 */
32 /**
33 * @name minify.json.js
34 * @author Kei Funagayama &lt;kei.topaz@gmail.com
35 * @overview JSON.minify
36 */
37
38 /**
39 * @namespace JSON
40 */
41 (function(global){
42 'use strict';
43
44 /**
45 * @function
46 * @memberof JSON
47 * @param {Object} Transformed data. format) json-like
48 * @return {String}
49 *
50 * @example
51 * var json = { // hoge
52 * "foo": "bar",// this is cool
53 * "bar": [
54 * "baz", "bum", "zam" // this is cool
55 * ]
56 * } // hoge
57 *
58 */
59 var minify = function (json) {
60
61 var tokenizer = /"|(\/\*)|(\*\/)|(\/\/)|\n|\r/g,
62 in_string = false,
63 in_multiline_comment = false,
64 in_singleline_comment = false,
65 tmp, tmp2, new_str = [], ns = 0, from = 0, lc, rc
66 ;
67
68 tokenizer.lastIndex = 0;
69
70 while ( tmp = tokenizer.exec(json) ) {
71 lc = RegExp.leftContext;
72 rc = RegExp.rightContext;
73 if (!in_multiline_comment && !in_singleline_comment) {
74 tmp2 = lc.substring(from);
75 if (!in_string) {
76 tmp2 = tmp2.replace(/(\n|\r|\s)*/g,"");
77 }
78 new_str[ns++] = tmp2;
79 }
80 from = tokenizer.lastIndex;
81
82 if (tmp[0] === "\"" && !in_multiline_comment && !in_singleline_comment) {
83 tmp2 = lc.match(/(\\)*$/);
84 if (!in_string || !tmp2 || (tmp2[0].length % 2) === 0) { // start of string with ", or unescaped " character found to end string
85 in_string = !in_string;
86 }
87 from--; // include " character in next catch
88 rc = json.substring(from);
89 }
90 else if (tmp[0] === "/*" && !in_string && !in_multiline_comment && !in_singleline_comment) {
91 in_multiline_comment = true;
92 }
93 else if (tmp[0] === "*/" && !in_string && in_multiline_comment && !in_singleline_comment) {
94 in_multiline_comment = false;
95 }
96 else if (tmp[0] === "//" && !in_string && !in_multiline_comment && !in_singleline_comment) {
97 in_singleline_comment = true;
98 }
99 else if ((tmp[0] === "\n" || tmp[0] === "\r") && !in_string && !in_multiline_comment && in_singleline_comment) {
100 in_singleline_comment = false;
101 }
102 else if (!in_multiline_comment && !in_singleline_comment && !(/\n|\r|\s/.test(tmp[0]))) {
103 new_str[ns++] = tmp[0];
104 }
105 }
106 new_str[ns++] = rc;
107 return new_str.join("");
108 };
109
110 if (typeof module !== 'undefined' && module.exports) {
111 // node
112 module.exports = minify;
113 JSON.minify = minify;
114 } else {
115 // others, export global
116 if (typeof global.JSON === "undefined" || !global.JSON) {
117 global.JSON = {};
118 }
119 global.JSON.minify = minify;
120 }
121 })(this);
122 </code></pre>
123 </article>
124 </section>
125
126
127
128
129 </div>
130
131 <nav>
132 <h2><a href="index.html">Index</a></h2><h3>Namespaces</h3><ul><li><a href="JSON.html">JSON</a></li></ul>
133 </nav>
134
135 <br clear="both">
136
137 <footer>
138 Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a> on Mon Sep 30 2013 14:37:29 GMT+0900 (JST)
139 </footer>
140
141 <script> prettyPrint(); </script>
142 <script src="scripts/linenumber.js"> </script>
143 </body>
144 </html>