services/sync/tps/extensions/mozmill/resource/stdlib/strings.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/services/sync/tps/extensions/mozmill/resource/stdlib/strings.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,17 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, you can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +var EXPORTED_SYMBOLS = ['trim', 'vslice'];
     1.9 +
    1.10 +var arrays = {}; Components.utils.import('resource://mozmill/stdlib/arrays.js', arrays);
    1.11 +
    1.12 +var trim = function (str) {
    1.13 +  return (str.replace(/^[\s\xA0]+/, "").replace(/[\s\xA0]+$/, ""));
    1.14 +}
    1.15 +
    1.16 +var vslice = function (str, svalue, evalue) {
    1.17 +  var sindex = arrays.indexOf(str, svalue);
    1.18 +  var eindex = arrays.rindexOf(str, evalue);
    1.19 +  return str.slice(sindex + 1, eindex);
    1.20 +}

mercurial