MCPcopy Create free account
hub / github.com/GNOME/gjs / trim

Function trim

modules/script/jsUnit.js:269–286  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

267}
268
269function trim(str) {
270 if (str == null)
271 return null;
272
273 var startingIndex = 0;
274 var endingIndex = str.length-1;
275
276 while (str.substring(startingIndex, startingIndex+1) == ' ')
277 startingIndex++;
278
279 while (str.substring(endingIndex, endingIndex+1) == ' ')
280 endingIndex--;
281
282 if (endingIndex < startingIndex)
283 return '';
284
285 return str.substring(startingIndex, endingIndex+1);
286}
287
288function isBlank(str) {
289 return trim(str) == '';

Callers 1

isBlankFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected