"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/es5-ext/string/format-method.js" (11 Apr 2017, 643 Bytes) of package /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 'use strict';
    2 
    3 var isCallable = require('../object/is-callable')
    4   , value      = require('../object/valid-value')
    5 
    6   , call = Function.prototype.call;
    7 
    8 module.exports = function (fmap) {
    9     fmap = Object(value(fmap));
   10     return function (pattern) {
   11         var context = value(this);
   12         pattern = String(pattern);
   13         return pattern.replace(/%([a-zA-Z]+)|\\([\u0000-\uffff])/g,
   14             function (match, token, escape) {
   15                 var t, r;
   16                 if (escape) return escape;
   17                 t = token;
   18                 while (t && !(r = fmap[t])) t = t.slice(0, -1);
   19                 if (!r) return match;
   20                 if (isCallable(r)) r = call.call(r, context);
   21                 return r + token.slice(t.length);
   22             });
   23     };
   24 };