]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/format-method.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / node-gyp / node_modules / path-array / node_modules / array-index / node_modules / es6-symbol / node_modules / es5-ext / string / format-method.js
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 };