Every line of 'jquery remove whitespace' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
17 function removeWhiteSpace(string) { 18 var whitePaceVar; 19 if(string === '' || string === null){ 20 whitePaceVar = ''; 21 }else{ 22 whitePaceVar = string.replace(/\s+/g, ''); 23 } 24 return whitePaceVar; 25 26 }
19 export function removeWhitespace(str) { 20 return str.replace(/\s/g, '') 21 }
24 export function fixWhiteSpace(text: string, whiteSpace: string) { 25 switch (whiteSpace) { 26 case 'normal': 27 case 'nowrap': 28 return text 29 .trim() 30 .replace(/\n/g, ' ')// replace newline characters with space 31 .replace(/\s+/g, ' '); // collapse whitespace 32 case 'pre-line': 33 return text 34 .replace(/(^[^\S\n]+)|([^\S\n]+$)/g, '')// trim but leave \n 35 .replace(/[^\S\n]+/g, ' ')// collapse whitespace (except \n) 36 .replace(/[^\S\n]?\n[^\S\n]?/g, '\n'); // remove whitespace before & after \n 37 default: 38 // pre, pre-wrap 39 } 40 return text; 41 }
33 function sanitizeWhitespace(string) { 34 return string ? (string + '').replace(RegExpWSChars, '').replace(RegExpMultiWS, ' ') : ''; 35 }
477 function stripWhitespace(str) { 478 return str.model_ ? str : str.replace(/[ \t\r\n\f]/g, ''); 479 }
183 function removeWhiteSpace(value) { 184 return value.replace(/\s/g, ''); 185 }
57 export function filterWhitespaceElements (val) { 58 if (typeof val.filter !== "function") return val; 59 return val.filter(item => { 60 return (typeof item === "string") ? /^\S+$/.test(item) : item; 61 }); 62 }
6 export function filter_whitespace(value) { 7 return value.replace(/\s+/g, ''); 8 }
4 function trimWhitespace(str) { 5 return str.replace(/(^\s+|\s+$)/g, ''); 6 }
55 function trimWhitespace(line) { 56 let whitespaceIndicies = []; 57 let allWhitespace = true; 58 let seenAnyTag = false; 59 let newLine = new Array(line.length); 60 for (let i = 0; i < line.length; i++) { 61 let obj = line[i]; 62 newLine[i] = obj; 63 if (typeof obj === 'string') { 64 if (!nonWhitespace.test(obj)) { 65 whitespaceIndicies.push(i); 66 } else { 67 allWhitespace = false; 68 } 69 } else { 70 seenAnyTag = true; 71 if (nonWhitespaceNodes[obj.type] === true) { 72 allWhitespace = false; 73 } 74 } 75 // Bail out if we've seen a non-whitespace 76 if (!allWhitespace) { 77 return line; 78 } 79 } 80 81 // Remove the whitespace nodes if this line consists of: 82 // - only whitespace text 83 // - no Interpolators or Unescaped Interpolators 84 // - at least one Mustache tag 85 if (allWhitespace && seenAnyTag) { 86 for (let i = 0; i < whitespaceIndicies.length; i++) { 87 let index = whitespaceIndicies[i]; 88 let obj = newLine[index]; 89 newLine[index] = { 90 type: types.TEXT, 91 original: obj, 92 length: obj.length 93 }; 94 } 95 } 96 97 return newLine; 98 }