is_nil function
This commit is contained in:
		
							
								
								
									
										43
									
								
								index.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										43
									
								
								index.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -1,10 +1,37 @@
 | 
				
			|||||||
/** Declaration file generated by dts-gen */
 | 
					/**
 | 
				
			||||||
 | 
					 * truncates a floating point number
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @param {number} num number to truncate
 | 
				
			||||||
 | 
					 * @param {number} len length to truncate to
 | 
				
			||||||
 | 
					 * @returns {number} truncated number
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					export function truncate_decimal(num: number, len: number): number;
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * parse json and catch invalid strings
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @param {string} text input
 | 
				
			||||||
 | 
					 * @returns {any} parsed
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					export function try_parse_json(text: string): any;
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * copy an object to prevent modification to the original
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @param {object} obj object to copy
 | 
				
			||||||
 | 
					 * @returns {object} copy
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
export function copy_object(obj: any): any;
 | 
					export function copy_object(obj: any): any;
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * run a regular expression and callback for every result
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @param {any} regex regular expression
 | 
				
			||||||
 | 
					 * @param {any} data data to run on
 | 
				
			||||||
 | 
					 * @param {any} func function to execute
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
export function run_regex(regex: any, data: any, func: any): void;
 | 
					export function run_regex(regex: any, data: any, func: any): void;
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
export function truncate_decimal(num: any, len: any): any;
 | 
					 * check if an object is either undefined, null or NaN
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
export function try_parse_json(text: any): any;
 | 
					 * @param {any} obj object to check
 | 
				
			||||||
 | 
					 * @returns {boolean} true if nil
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					export function is_nil(obj: any): boolean;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										14
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								index.js
									
									
									
									
									
								
							@@ -66,10 +66,22 @@ function run_regex (regex, data, func) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * check if an object is either undefined, null or NaN
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @param {any} obj object to check
 | 
				
			||||||
 | 
					 * @returns {boolean} true if nil
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					function is_nil (obj) {
 | 
				
			||||||
 | 
					  return typeof obj === 'undefined'
 | 
				
			||||||
 | 
					      || obj === null
 | 
				
			||||||
 | 
					      || (typeof obj === 'number' && isNaN (obj));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = {
 | 
					module.exports = {
 | 
				
			||||||
  truncate_decimal,
 | 
					  truncate_decimal,
 | 
				
			||||||
  try_parse_json,
 | 
					  try_parse_json,
 | 
				
			||||||
  copy_object,
 | 
					  copy_object,
 | 
				
			||||||
  run_regex
 | 
					  run_regex,
 | 
				
			||||||
 | 
					  is_nil
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user