11'use strict' ;
22
33/**
4+ * A property--value pair tuple.
5+ *
6+ * @typedef {Array } Pair
7+ * @typedef {string } Pair.0
8+ * @typedef {string } Pair.1
9+ */
10+
11+ /*
412 * Cached methods.
513 */
614
@@ -14,15 +22,13 @@ has = Object.prototype.hasOwnProperty;
1422 * @param {string } token
1523 * @return {function(string): string }
1624 */
17-
1825function stripComments ( token ) {
1926 /**
2027 * Strip comments.
2128 *
2229 * @param {string } value - Line.
2330 * @return {string } Value with comments removed.
2431 */
25-
2632 return function ( value ) {
2733 var index ;
2834
@@ -43,7 +49,6 @@ function stripComments(token) {
4349 * @return {string } Value with initial and final white
4450 * space removed.
4551 */
46-
4752function trimWhiteSpace ( value ) {
4853 return value . trim ( ) ;
4954}
@@ -54,7 +59,6 @@ function trimWhiteSpace(value) {
5459 * @param {string } value
5560 * @return {boolean }
5661 */
57-
5862function isNonEmpty ( value ) {
5963 return Boolean ( value ) ;
6064}
@@ -63,18 +67,15 @@ function isNonEmpty(value) {
6367 * Factory to transform lines to property--value tuples.
6468 *
6569 * @param {string } token
66- * @return {function(string): {0: string, 1: string} }
70+ * @return {function(string): Pair }
6771 */
68-
6972function toPropertyValuePairs ( token ) {
7073 /**
7174 * Transform `value` to a property--value tuple.
7275 *
7376 * @param {string } value - Line.
74- * @return {{0: string, 1: string} } Array with
75- * property at `0` and value at `1`.
77+ * @return {Pair }
7678 */
77-
7879 return function ( value ) {
7980 var values ,
8081 result ;
@@ -95,21 +96,20 @@ function toPropertyValuePairs(token) {
9596 *
9697 * To be passed to `Array#sort()`.
9798 *
98- * @param {{0: *} } a
99- * @param {{0: *} } b
99+ * @param {Pair } a
100+ * @param {Pair } b
101+ * @return {number }
100102 */
101-
102103function sortOnFirstIndex ( a , b ) {
103104 return a [ 0 ] . charCodeAt ( 0 ) - b [ 0 ] . charCodeAt ( 0 ) ;
104105}
105106
106107/**
107- * Transform a list of key --value tuples to an object.
108+ * Transform a list of property --value tuples to an object.
108109 *
109- * @param {Array.<{0: string, 1: string} > } pairs
110+ * @param {Array.<Pair > } pairs
110111 * @return {Object.<string, string> }
111112 */
112-
113113function propertyValuePairsToObject ( pairs ) {
114114 var values ;
115115
@@ -126,10 +126,13 @@ function propertyValuePairsToObject(pairs) {
126126 * Transform a string into an array or object of values.
127127 *
128128 * @param {string } value
129- * @param {Object? } options
129+ * @param {?Object } options
130+ * @param {?boolean } options.log
131+ * @param {?(string|boolean) } options.comment
132+ * @param {?(string|boolean) } options.delimiter
133+ * @param {?(string|boolean) } options.fix
130134 * @return {Object.<string, string>|Array.<string> }
131135 */
132-
133136function textToJSON ( value , options ) {
134137 var propertyOrValues ,
135138 lines ,
0 commit comments