Team Ai
Datasetpublic

Brunobkr/llama.cpp_AlgMor24_github

ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes3.1kdownloads
ejs.js1747 linesDownload Raw Back to ejs
1(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ejs = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){2/*3 * EJS Embedded JavaScript templates4 * Copyright 2112 Matthew Eernisse (mde@fleegix.org)5 *6 * Licensed under the Apache License, Version 2.0 (the "License");7 * you may not use this file except in compliance with the License.8 * You may obtain a copy of the License at9 *10 *         http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * distributed under the License is distributed on an "AS IS" BASIS,14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15 * See the License for the specific language governing permissions and16 * limitations under the License.17 *18*/19 20'use strict';21 22/**23 * @file Embedded JavaScript templating engine. {@link http://ejs.co}24 * @author Matthew Eernisse <mde@fleegix.org>25 * @author Tiancheng "Timothy" Gu <timothygu99@gmail.com>26 * @project EJS27 * @license {@link http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0}28 */29 30/**31 * EJS internal functions.32 *33 * Technically this "module" lies in the same file as {@link module:ejs}, for34 * the sake of organization all the private functions re grouped into this35 * module.36 *37 * @module ejs-internal38 * @private39 */40 41/**42 * Embedded JavaScript templating engine.43 *44 * @module ejs45 * @public46 */47 48 49var fs = require('fs');50var path = require('path');51var utils = require('./utils');52 53var scopeOptionWarned = false;54/** @type {string} */55var _VERSION_STRING = require('../package.json').version;56var _DEFAULT_OPEN_DELIMITER = '<';57var _DEFAULT_CLOSE_DELIMITER = '>';58var _DEFAULT_DELIMITER = '%';59var _DEFAULT_LOCALS_NAME = 'locals';60var _NAME = 'ejs';61var _REGEX_STRING = '(<%%|%%>|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)';62var _OPTS_PASSABLE_WITH_DATA = ['delimiter', 'scope', 'context', 'debug', 'compileDebug',63  'client', '_with', 'rmWhitespace', 'strict', 'filename', 'async'];64// We don't allow 'cache' option to be passed in the data obj for65// the normal `render` call, but this is where Express 2 & 3 put it66// so we make an exception for `renderFile`67var _OPTS_PASSABLE_WITH_DATA_EXPRESS = _OPTS_PASSABLE_WITH_DATA.concat('cache');68var _BOM = /^\uFEFF/;69var _JS_IDENTIFIER = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;70 71/**72 * EJS template function cache. This can be a LRU object from lru-cache NPM73 * module. By default, it is {@link module:utils.cache}, a simple in-process74 * cache that grows continuously.75 *76 * @type {Cache}77 */78 79exports.cache = utils.cache;80 81/**82 * Custom file loader. Useful for template preprocessing or restricting access83 * to a certain part of the filesystem.84 *85 * @type {fileLoader}86 */87 88exports.fileLoader = fs.readFileSync;89 90/**91 * Name of the object containing the locals.92 *93 * This variable is overridden by {@link Options}`.localsName` if it is not94 * `undefined`.95 *96 * @type {String}97 * @public98 */99 100exports.localsName = _DEFAULT_LOCALS_NAME;101 102/**103 * Promise implementation -- defaults to the native implementation if available104 * This is mostly just for testability105 *106 * @type {PromiseConstructorLike}107 * @public108 */109 110exports.promiseImpl = (new Function('return this;'))().Promise;111 112/**113 * Get the path to the included file from the parent file path and the114 * specified path.115 *116 * @param {String}  name     specified path117 * @param {String}  filename parent file path118 * @param {Boolean} [isDir=false] whether the parent file path is a directory119 * @return {String}120 */121exports.resolveInclude = function(name, filename, isDir) {122  var dirname = path.dirname;123  var extname = path.extname;124  var resolve = path.resolve;125  var includePath = resolve(isDir ? filename : dirname(filename), name);126  var ext = extname(name);127  if (!ext) {128    includePath += '.ejs';129  }130  return includePath;131};132 133/**134 * Try to resolve file path on multiple directories135 *136 * @param  {String}        name  specified path137 * @param  {Array<String>} paths list of possible parent directory paths138 * @return {String}139 */140function resolvePaths(name, paths) {141  var filePath;142  if (paths.some(function (v) {143    filePath = exports.resolveInclude(name, v, true);144    return fs.existsSync(filePath);145  })) {146    return filePath;147  }148}149 150/**151 * Get the path to the included file by Options152 *153 * @param  {String}  path    specified path154 * @param  {Options} options compilation options155 * @return {String}156 */157function getIncludePath(path, options) {158  var includePath;159  var filePath;160  var views = options.views;161  var match = /^[A-Za-z]+:\\|^\//.exec(path);162 163  // Abs path164  if (match && match.length) {165    path = path.replace(/^\/*/, '');166    if (Array.isArray(options.root)) {167      includePath = resolvePaths(path, options.root);168    } else {169      includePath = exports.resolveInclude(path, options.root || '/', true);170    }171  }172  // Relative paths173  else {174    // Look relative to a passed filename first175    if (options.filename) {176      filePath = exports.resolveInclude(path, options.filename);177      if (fs.existsSync(filePath)) {178        includePath = filePath;179      }180    }181    // Then look in any views directories182    if (!includePath && Array.isArray(views)) {183      includePath = resolvePaths(path, views);184    }185    if (!includePath && typeof options.includer !== 'function') {186      throw new Error('Could not find the include file "' +187          options.escapeFunction(path) + '"');188    }189  }190  return includePath;191}192 193/**194 * Get the template from a string or a file, either compiled on-the-fly or195 * read from cache (if enabled), and cache the template if needed.196 *197 * If `template` is not set, the file specified in `options.filename` will be198 * read.199 *200 * If `options.cache` is true, this function reads the file from201 * `options.filename` so it must be set prior to calling this function.202 *203 * @memberof module:ejs-internal204 * @param {Options} options   compilation options205 * @param {String} [template] template source206 * @return {(TemplateFunction|ClientFunction)}207 * Depending on the value of `options.client`, either type might be returned.208 * @static209 */210 211function handleCache(options, template) {212  var func;213  var filename = options.filename;214  var hasTemplate = arguments.length > 1;215 216  if (options.cache) {217    if (!filename) {218      throw new Error('cache option requires a filename');219    }220    func = exports.cache.get(filename);221    if (func) {222      return func;223    }224    if (!hasTemplate) {225      template = fileLoader(filename).toString().replace(_BOM, '');226    }227  }228  else if (!hasTemplate) {229    // istanbul ignore if: should not happen at all230    if (!filename) {231      throw new Error('Internal EJS error: no file name or template '232                    + 'provided');233    }234    template = fileLoader(filename).toString().replace(_BOM, '');235  }236  func = exports.compile(template, options);237  if (options.cache) {238    exports.cache.set(filename, func);239  }240  return func;241}242 243/**244 * Try calling handleCache with the given options and data and call the245 * callback with the result. If an error occurs, call the callback with246 * the error. Used by renderFile().247 *248 * @memberof module:ejs-internal249 * @param {Options} options    compilation options250 * @param {Object} data        template data251 * @param {RenderFileCallback} cb callback252 * @static253 */254 255function tryHandleCache(options, data, cb) {256  var result;257  if (!cb) {258    if (typeof exports.promiseImpl == 'function') {259      return new exports.promiseImpl(function (resolve, reject) {260        try {261          result = handleCache(options)(data);262          resolve(result);263        }264        catch (err) {265          reject(err);266        }267      });268    }269    else {270      throw new Error('Please provide a callback function');271    }272  }273  else {274    try {275      result = handleCache(options)(data);276    }277    catch (err) {278      return cb(err);279    }280 281    cb(null, result);282  }283}284 285/**286 * fileLoader is independent287 *288 * @param {String} filePath ejs file path.289 * @return {String} The contents of the specified file.290 * @static291 */292 293function fileLoader(filePath){294  return exports.fileLoader(filePath);295}296 297/**298 * Get the template function.299 *300 * If `options.cache` is `true`, then the template is cached.301 *302 * @memberof module:ejs-internal303 * @param {String}  path    path for the specified file304 * @param {Options} options compilation options305 * @return {(TemplateFunction|ClientFunction)}306 * Depending on the value of `options.client`, either type might be returned307 * @static308 */309 310function includeFile(path, options) {311  var opts = utils.shallowCopy(utils.createNullProtoObjWherePossible(), options);312  opts.filename = getIncludePath(path, opts);313  if (typeof options.includer === 'function') {314    var includerResult = options.includer(path, opts.filename);315    if (includerResult) {316      if (includerResult.filename) {317        opts.filename = includerResult.filename;318      }319      if (includerResult.template) {320        return handleCache(opts, includerResult.template);321      }322    }323  }324  return handleCache(opts);325}326 327/**328 * Re-throw the given `err` in context to the `str` of ejs, `filename`, and329 * `lineno`.330 *331 * @implements {RethrowCallback}332 * @memberof module:ejs-internal333 * @param {Error}  err      Error object334 * @param {String} str      EJS source335 * @param {String} flnm     file name of the EJS file336 * @param {Number} lineno   line number of the error337 * @param {EscapeCallback} esc338 * @static339 */340 341function rethrow(err, str, flnm, lineno, esc) {342  var lines = str.split('\n');343  var start = Math.max(lineno - 3, 0);344  var end = Math.min(lines.length, lineno + 3);345  var filename = esc(flnm);346  // Error context347  var context = lines.slice(start, end).map(function (line, i){348    var curr = i + start + 1;349    return (curr == lineno ? ' >> ' : '    ')350      + curr351      + '| '352      + line;353  }).join('\n');354 355  // Alter exception message356  err.path = filename;357  err.message = (filename || 'ejs') + ':'358    + lineno + '\n'359    + context + '\n\n'360    + err.message;361 362  throw err;363}364 365function stripSemi(str){366  return str.replace(/;(\s*$)/, '$1');367}368 369/**370 * Compile the given `str` of ejs into a template function.371 *372 * @param {String}  template EJS template373 *374 * @param {Options} [opts] compilation options375 *376 * @return {(TemplateFunction|ClientFunction)}377 * Depending on the value of `opts.client`, either type might be returned.378 * Note that the return type of the function also depends on the value of `opts.async`.379 * @public380 */381 382exports.compile = function compile(template, opts) {383  var templ;384 385  // v1 compat386  // 'scope' is 'context'387  // FIXME: Remove this in a future version388  if (opts && opts.scope) {389    if (!scopeOptionWarned){390      console.warn('`scope` option is deprecated and will be removed in EJS 3');391      scopeOptionWarned = true;392    }393    if (!opts.context) {394      opts.context = opts.scope;395    }396    delete opts.scope;397  }398  templ = new Template(template, opts);399  return templ.compile();400};401 402/**403 * Render the given `template` of ejs.404 *405 * If you would like to include options but not data, you need to explicitly406 * call this function with `data` being an empty object or `null`.407 *408 * @param {String}   template EJS template409 * @param {Object}  [data={}] template data410 * @param {Options} [opts={}] compilation and rendering options411 * @return {(String|Promise<String>)}412 * Return value type depends on `opts.async`.413 * @public414 */415 416exports.render = function (template, d, o) {417  var data = d || utils.createNullProtoObjWherePossible();418  var opts = o || utils.createNullProtoObjWherePossible();419 420  // No options object -- if there are optiony names421  // in the data, copy them to options422  if (arguments.length == 2) {423    utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA);424  }425 426  return handleCache(opts, template)(data);427};428 429/**430 * Render an EJS file at the given `path` and callback `cb(err, str)`.431 *432 * If you would like to include options but not data, you need to explicitly433 * call this function with `data` being an empty object or `null`.434 *435 * @param {String}             path     path to the EJS file436 * @param {Object}            [data={}] template data437 * @param {Options}           [opts={}] compilation and rendering options438 * @param {RenderFileCallback} cb callback439 * @public440 */441 442exports.renderFile = function () {443  var args = Array.prototype.slice.call(arguments);444  var filename = args.shift();445  var cb;446  var opts = {filename: filename};447  var data;448  var viewOpts;449 450  // Do we have a callback?451  if (typeof arguments[arguments.length - 1] == 'function') {452    cb = args.pop();453  }454  // Do we have data/opts?455  if (args.length) {456    // Should always have data obj457    data = args.shift();458    // Normal passed opts (data obj + opts obj)459    if (args.length) {460      // Use shallowCopy so we don't pollute passed in opts obj with new vals461      utils.shallowCopy(opts, args.pop());462    }463    // Special casing for Express (settings + opts-in-data)464    else {465      // Express 3 and 4466      if (data.settings) {467        // Pull a few things from known locations468        if (data.settings.views) {469          opts.views = data.settings.views;470        }471        if (data.settings['view cache']) {472          opts.cache = true;473        }474        // Undocumented after Express 2, but still usable, esp. for475        // items that are unsafe to be passed along with data, like `root`476        viewOpts = data.settings['view options'];477        if (viewOpts) {478          utils.shallowCopy(opts, viewOpts);479        }480      }481      // Express 2 and lower, values set in app.locals, or people who just482      // want to pass options in their data. NOTE: These values will override483      // anything previously set in settings  or settings['view options']484      utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA_EXPRESS);485    }486    opts.filename = filename;487  }488  else {489    data = utils.createNullProtoObjWherePossible();490  }491 492  return tryHandleCache(opts, data, cb);493};494 495/**496 * Clear intermediate JavaScript cache. Calls {@link Cache#reset}.497 * @public498 */499 500/**501 * EJS template class502 * @public503 */504exports.Template = Template;505 506exports.clearCache = function () {507  exports.cache.reset();508};509 510function Template(text, optsParam) {511  var opts = utils.hasOwnOnlyObject(optsParam);512  var options = utils.createNullProtoObjWherePossible();513  this.templateText = text;514  /** @type {string | null} */515  this.mode = null;516  this.truncate = false;517  this.currentLine = 1;518  this.source = '';519  options.client = opts.client || false;520  options.escapeFunction = opts.escape || opts.escapeFunction || utils.escapeXML;521  options.compileDebug = opts.compileDebug !== false;522  options.debug = !!opts.debug;523  options.filename = opts.filename;524  options.openDelimiter = opts.openDelimiter || exports.openDelimiter || _DEFAULT_OPEN_DELIMITER;525  options.closeDelimiter = opts.closeDelimiter || exports.closeDelimiter || _DEFAULT_CLOSE_DELIMITER;526  options.delimiter = opts.delimiter || exports.delimiter || _DEFAULT_DELIMITER;527  options.strict = opts.strict || false;528  options.context = opts.context;529  options.cache = opts.cache || false;530  options.rmWhitespace = opts.rmWhitespace;531  options.root = opts.root;532  options.includer = opts.includer;533  options.outputFunctionName = opts.outputFunctionName;534  options.localsName = opts.localsName || exports.localsName || _DEFAULT_LOCALS_NAME;535  options.views = opts.views;536  options.async = opts.async;537  options.destructuredLocals = opts.destructuredLocals;538  options.legacyInclude = typeof opts.legacyInclude != 'undefined' ? !!opts.legacyInclude : true;539 540  if (options.strict) {541    options._with = false;542  }543  else {544    options._with = typeof opts._with != 'undefined' ? opts._with : true;545  }546 547  this.opts = options;548 549  this.regex = this.createRegex();550}551 552Template.modes = {553  EVAL: 'eval',554  ESCAPED: 'escaped',555  RAW: 'raw',556  COMMENT: 'comment',557  LITERAL: 'literal'558};559 560Template.prototype = {561  createRegex: function () {562    var str = _REGEX_STRING;563    var delim = utils.escapeRegExpChars(this.opts.delimiter);564    var open = utils.escapeRegExpChars(this.opts.openDelimiter);565    var close = utils.escapeRegExpChars(this.opts.closeDelimiter);566    str = str.replace(/%/g, delim)567      .replace(/</g, open)568      .replace(/>/g, close);569    return new RegExp(str);570  },571 572  compile: function () {573    /** @type {string} */574    var src;575    /** @type {ClientFunction} */576    var fn;577    var opts = this.opts;578    var prepended = '';579    var appended = '';580    /** @type {EscapeCallback} */581    var escapeFn = opts.escapeFunction;582    /** @type {FunctionConstructor} */583    var ctor;584    /** @type {string} */585    var sanitizedFilename = opts.filename ? JSON.stringify(opts.filename) : 'undefined';586 587    if (!this.source) {588      this.generateSource();589      prepended +=590        '  var __output = "";\n' +591        '  function __append(s) { if (s !== undefined && s !== null) __output += s }\n';592      if (opts.outputFunctionName) {593        if (!_JS_IDENTIFIER.test(opts.outputFunctionName)) {594          throw new Error('outputFunctionName is not a valid JS identifier.');595        }596        prepended += '  var ' + opts.outputFunctionName + ' = __append;' + '\n';597      }598      if (opts.localsName && !_JS_IDENTIFIER.test(opts.localsName)) {599        throw new Error('localsName is not a valid JS identifier.');600      }601      if (opts.destructuredLocals && opts.destructuredLocals.length) {602        var destructuring = '  var __locals = (' + opts.localsName + ' || {}),\n';603        for (var i = 0; i < opts.destructuredLocals.length; i++) {604          var name = opts.destructuredLocals[i];605          if (!_JS_IDENTIFIER.test(name)) {606            throw new Error('destructuredLocals[' + i + '] is not a valid JS identifier.');607          }608          if (i > 0) {609            destructuring += ',\n  ';610          }611          destructuring += name + ' = __locals.' + name;612        }613        prepended += destructuring + ';\n';614      }615      if (opts._with !== false) {616        prepended +=  '  with (' + opts.localsName + ' || {}) {' + '\n';617        appended += '  }' + '\n';618      }619      appended += '  return __output;' + '\n';620      this.source = prepended + this.source + appended;621    }622 623    if (opts.compileDebug) {624      src = 'var __line = 1' + '\n'625        + '  , __lines = ' + JSON.stringify(this.templateText) + '\n'626        + '  , __filename = ' + sanitizedFilename + ';' + '\n'627        + 'try {' + '\n'628        + this.source629        + '} catch (e) {' + '\n'630        + '  rethrow(e, __lines, __filename, __line, escapeFn);' + '\n'631        + '}' + '\n';632    }633    else {634      src = this.source;635    }636 637    if (opts.client) {638      src = 'escapeFn = escapeFn || ' + escapeFn.toString() + ';' + '\n' + src;639      if (opts.compileDebug) {640        src = 'rethrow = rethrow || ' + rethrow.toString() + ';' + '\n' + src;641      }642    }643 644    if (opts.strict) {645      src = '"use strict";\n' + src;646    }647    if (opts.debug) {648      console.log(src);649    }650    if (opts.compileDebug && opts.filename) {651      src = src + '\n'652        + '//# sourceURL=' + sanitizedFilename + '\n';653    }654 655    try {656      if (opts.async) {657        // Have to use generated function for this, since in envs without support,658        // it breaks in parsing659        try {660          ctor = (new Function('return (async function(){}).constructor;'))();661        }662        catch(e) {663          if (e instanceof SyntaxError) {664            throw new Error('This environment does not support async/await');665          }666          else {667            throw e;668          }669        }670      }671      else {672        ctor = Function;673      }674      fn = new ctor(opts.localsName + ', escapeFn, include, rethrow', src);675    }676    catch(e) {677      // istanbul ignore else678      if (e instanceof SyntaxError) {679        if (opts.filename) {680          e.message += ' in ' + opts.filename;681        }682        e.message += ' while compiling ejs\n\n';683        e.message += 'If the above error is not helpful, you may want to try EJS-Lint:\n';684        e.message += 'https://github.com/RyanZim/EJS-Lint';685        if (!opts.async) {686          e.message += '\n';687          e.message += 'Or, if you meant to create an async function, pass `async: true` as an option.';688        }689      }690      throw e;691    }692 693    // Return a callable function which will execute the function694    // created by the source-code, with the passed data as locals695    // Adds a local `include` function which allows full recursive include696    var returnedFn = opts.client ? fn : function anonymous(data) {697      var include = function (path, includeData) {698        var d = utils.shallowCopy(utils.createNullProtoObjWherePossible(), data);699        if (includeData) {700          d = utils.shallowCopy(d, includeData);701        }702        return includeFile(path, opts)(d);703      };704      return fn.apply(opts.context,705        [data || utils.createNullProtoObjWherePossible(), escapeFn, include, rethrow]);706    };707    if (opts.filename && typeof Object.defineProperty === 'function') {708      var filename = opts.filename;709      var basename = path.basename(filename, path.extname(filename));710      try {711        Object.defineProperty(returnedFn, 'name', {712          value: basename,713          writable: false,714          enumerable: false,715          configurable: true716        });717      } catch (e) {/* ignore */}718    }719    return returnedFn;720  },721 722  generateSource: function () {723    var opts = this.opts;724 725    if (opts.rmWhitespace) {726      // Have to use two separate replace here as `^` and `$` operators don't727      // work well with `\r` and empty lines don't work well with the `m` flag.728      this.templateText =729        this.templateText.replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');730    }731 732    // Slurp spaces and tabs before <%_ and after _%>733    this.templateText =734      this.templateText.replace(/[ \t]*<%_/gm, '<%_').replace(/_%>[ \t]*/gm, '_%>');735 736    var self = this;737    var matches = this.parseTemplateText();738    var d = this.opts.delimiter;739    var o = this.opts.openDelimiter;740    var c = this.opts.closeDelimiter;741 742    if (matches && matches.length) {743      matches.forEach(function (line, index) {744        var closing;745        // If this is an opening tag, check for closing tags746        // FIXME: May end up with some false positives here747        // Better to store modes as k/v with openDelimiter + delimiter as key748        // Then this can simply check against the map749        if ( line.indexOf(o + d) === 0        // If it is a tag750          && line.indexOf(o + d + d) !== 0) { // and is not escaped751          closing = matches[index + 2];752          if (!(closing == d + c || closing == '-' + d + c || closing == '_' + d + c)) {753            throw new Error('Could not find matching close tag for "' + line + '".');754          }755        }756        self.scanLine(line);757      });758    }759 760  },761 762  parseTemplateText: function () {763    var str = this.templateText;764    var pat = this.regex;765    var result = pat.exec(str);766    var arr = [];767    var firstPos;768 769    while (result) {770      firstPos = result.index;771 772      if (firstPos !== 0) {773        arr.push(str.substring(0, firstPos));774        str = str.slice(firstPos);775      }776 777      arr.push(result[0]);778      str = str.slice(result[0].length);779      result = pat.exec(str);780    }781 782    if (str) {783      arr.push(str);784    }785 786    return arr;787  },788 789  _addOutput: function (line) {790    if (this.truncate) {791      // Only replace single leading linebreak in the line after792      // -%> tag -- this is the single, trailing linebreak793      // after the tag that the truncation mode replaces794      // Handle Win / Unix / old Mac linebreaks -- do the \r\n795      // combo first in the regex-or796      line = line.replace(/^(?:\r\n|\r|\n)/, '');797      this.truncate = false;798    }799    if (!line) {800      return line;801    }802 803    // Preserve literal slashes804    line = line.replace(/\\/g, '\\\\');805 806    // Convert linebreaks807    line = line.replace(/\n/g, '\\n');808    line = line.replace(/\r/g, '\\r');809 810    // Escape double-quotes811    // - this will be the delimiter during execution812    line = line.replace(/"/g, '\\"');813    this.source += '    ; __append("' + line + '")' + '\n';814  },815 816  scanLine: function (line) {817    var self = this;818    var d = this.opts.delimiter;819    var o = this.opts.openDelimiter;820    var c = this.opts.closeDelimiter;821    var newLineCount = 0;822 823    newLineCount = (line.split('\n').length - 1);824 825    switch (line) {826    case o + d:827    case o + d + '_':828      this.mode = Template.modes.EVAL;829      break;830    case o + d + '=':831      this.mode = Template.modes.ESCAPED;832      break;833    case o + d + '-':834      this.mode = Template.modes.RAW;835      break;836    case o + d + '#':837      this.mode = Template.modes.COMMENT;838      break;839    case o + d + d:840      this.mode = Template.modes.LITERAL;841      this.source += '    ; __append("' + line.replace(o + d + d, o + d) + '")' + '\n';842      break;843    case d + d + c:844      this.mode = Template.modes.LITERAL;845      this.source += '    ; __append("' + line.replace(d + d + c, d + c) + '")' + '\n';846      break;847    case d + c:848    case '-' + d + c:849    case '_' + d + c:850      if (this.mode == Template.modes.LITERAL) {851        this._addOutput(line);852      }853 854      this.mode = null;855      this.truncate = line.indexOf('-') === 0 || line.indexOf('_') === 0;856      break;857    default:858      // In script mode, depends on type of tag859      if (this.mode) {860        // If '//' is found without a line break, add a line break.861        switch (this.mode) {862        case Template.modes.EVAL:863        case Template.modes.ESCAPED:864        case Template.modes.RAW:865          if (line.lastIndexOf('//') > line.lastIndexOf('\n')) {866            line += '\n';867          }868        }869        switch (this.mode) {870        // Just executing code871        case Template.modes.EVAL:872          this.source += '    ; ' + line + '\n';873          break;874          // Exec, esc, and output875        case Template.modes.ESCAPED:876          this.source += '    ; __append(escapeFn(' + stripSemi(line) + '))' + '\n';877          break;878          // Exec and output879        case Template.modes.RAW:880          this.source += '    ; __append(' + stripSemi(line) + ')' + '\n';881          break;882        case Template.modes.COMMENT:883          // Do nothing884          break;885          // Literal <%% mode, append as raw output886        case Template.modes.LITERAL:887          this._addOutput(line);888          break;889        }890      }891      // In string mode, just add the output892      else {893        this._addOutput(line);894      }895    }896 897    if (self.opts.compileDebug && newLineCount) {898      this.currentLine += newLineCount;899      this.source += '    ; __line = ' + this.currentLine + '\n';900    }901  }902};903 904/**905 * Escape characters reserved in XML.906 *907 * This is simply an export of {@link module:utils.escapeXML}.908 *909 * If `markup` is `undefined` or `null`, the empty string is returned.910 *911 * @param {String} markup Input string912 * @return {String} Escaped string913 * @public914 * @func915 * */916exports.escapeXML = utils.escapeXML;917 918/**919 * Express.js support.920 *921 * This is an alias for {@link module:ejs.renderFile}, in order to support922 * Express.js out-of-the-box.923 *924 * @func925 */926 927exports.__express = exports.renderFile;928 929/**930 * Version of EJS.931 *932 * @readonly933 * @type {String}934 * @public935 */936 937exports.VERSION = _VERSION_STRING;938 939/**940 * Name for detection of EJS.941 *942 * @readonly943 * @type {String}944 * @public945 */946 947exports.name = _NAME;948 949/* istanbul ignore if */950if (typeof window != 'undefined') {951  window.ejs = exports;952}953 954 955},{"../package.json":6,"./utils":2,"fs":3,"path":4}],2:[function(require,module,exports){956/*957 * EJS Embedded JavaScript templates958 * Copyright 2112 Matthew Eernisse (mde@fleegix.org)959 *960 * Licensed under the Apache License, Version 2.0 (the "License");961 * you may not use this file except in compliance with the License.962 * You may obtain a copy of the License at963 *964 *         http://www.apache.org/licenses/LICENSE-2.0965 *966 * Unless required by applicable law or agreed to in writing, software967 * distributed under the License is distributed on an "AS IS" BASIS,968 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.969 * See the License for the specific language governing permissions and970 * limitations under the License.971 *972*/973 974/**975 * Private utility functions976 * @module utils977 * @private978 */979 980'use strict';981 982var regExpChars = /[|\\{}()[\]^$+*?.]/g;983var hasOwnProperty = Object.prototype.hasOwnProperty;984var hasOwn = function (obj, key) { return hasOwnProperty.apply(obj, [key]); };985 986/**987 * Escape characters reserved in regular expressions.988 *989 * If `string` is `undefined` or `null`, the empty string is returned.990 *991 * @param {String} string Input string992 * @return {String} Escaped string993 * @static994 * @private995 */996exports.escapeRegExpChars = function (string) {997  // istanbul ignore if998  if (!string) {999    return '';1000  }1001  return String(string).replace(regExpChars, '\\$&');1002};1003 1004var _ENCODE_HTML_RULES = {1005  '&': '&amp;',1006  '<': '&lt;',1007  '>': '&gt;',1008  '"': '&#34;',1009  "'": '&#39;'1010};1011var _MATCH_HTML = /[&<>'"]/g;1012 1013function encode_char(c) {1014  return _ENCODE_HTML_RULES[c] || c;1015}1016 1017/**1018 * Stringified version of constants used by {@link module:utils.escapeXML}.1019 *1020 * It is used in the process of generating {@link ClientFunction}s.1021 *1022 * @readonly1023 * @type {String}1024 */1025 1026var escapeFuncStr =1027  'var _ENCODE_HTML_RULES = {\n'1028+ '      "&": "&amp;"\n'1029+ '    , "<": "&lt;"\n'1030+ '    , ">": "&gt;"\n'1031+ '    , \'"\': "&#34;"\n'1032+ '    , "\'": "&#39;"\n'1033+ '    }\n'1034+ '  , _MATCH_HTML = /[&<>\'"]/g;\n'1035+ 'function encode_char(c) {\n'1036+ '  return _ENCODE_HTML_RULES[c] || c;\n'1037+ '};\n';1038 1039/**1040 * Escape characters reserved in XML.1041 *1042 * If `markup` is `undefined` or `null`, the empty string is returned.1043 *1044 * @implements {EscapeCallback}1045 * @param {String} markup Input string1046 * @return {String} Escaped string1047 * @static1048 * @private1049 */1050 1051exports.escapeXML = function (markup) {1052  return markup == undefined1053    ? ''1054    : String(markup)1055      .replace(_MATCH_HTML, encode_char);1056};1057 1058function escapeXMLToString() {1059  return Function.prototype.toString.call(this) + ';\n' + escapeFuncStr;1060}1061 1062try {1063  if (typeof Object.defineProperty === 'function') {1064  // If the Function prototype is frozen, the "toString" property is non-writable. This means that any objects which inherit this property1065  // cannot have the property changed using an assignment. If using strict mode, attempting that will cause an error. If not using strict1066  // mode, attempting that will be silently ignored.1067  // However, we can still explicitly shadow the prototype's "toString" property by defining a new "toString" property on this object.1068    Object.defineProperty(exports.escapeXML, 'toString', { value: escapeXMLToString });1069  } else {1070    // If Object.defineProperty() doesn't exist, attempt to shadow this property using the assignment operator.1071    exports.escapeXML.toString = escapeXMLToString;1072  }1073} catch (err) {1074  console.warn('Unable to set escapeXML.toString (is the Function prototype frozen?)');1075}1076 1077/**1078 * Naive copy of properties from one object to another.1079 * Does not recurse into non-scalar properties1080 * Does not check to see if the property has a value before copying1081 *1082 * @param  {Object} to   Destination object1083 * @param  {Object} from Source object1084 * @return {Object}      Destination object1085 * @static1086 * @private1087 */1088exports.shallowCopy = function (to, from) {1089  from = from || {};1090  if ((to !== null) && (to !== undefined)) {1091    for (var p in from) {1092      if (!hasOwn(from, p)) {1093        continue;1094      }1095      if (p === '__proto__' || p === 'constructor') {1096        continue;1097      }1098      to[p] = from[p];1099    }1100  }1101  return to;1102};1103 1104/**1105 * Naive copy of a list of key names, from one object to another.1106 * Only copies property if it is actually defined1107 * Does not recurse into non-scalar properties1108 *1109 * @param  {Object} to   Destination object1110 * @param  {Object} from Source object1111 * @param  {Array} list List of properties to copy1112 * @return {Object}      Destination object1113 * @static1114 * @private1115 */1116exports.shallowCopyFromList = function (to, from, list) {1117  list = list || [];1118  from = from || {};1119  if ((to !== null) && (to !== undefined)) {1120    for (var i = 0; i < list.length; i++) {1121      var p = list[i];1122      if (typeof from[p] != 'undefined') {1123        if (!hasOwn(from, p)) {1124          continue;1125        }1126        if (p === '__proto__' || p === 'constructor') {1127          continue;1128        }1129        to[p] = from[p];1130      }1131    }1132  }1133  return to;1134};1135 1136/**1137 * Simple in-process cache implementation. Does not implement limits of any1138 * sort.1139 *1140 * @implements {Cache}1141 * @static1142 * @private1143 */1144exports.cache = {1145  _data: {},1146  set: function (key, val) {1147    this._data[key] = val;1148  },1149  get: function (key) {1150    return this._data[key];1151  },1152  remove: function (key) {1153    delete this._data[key];1154  },1155  reset: function () {1156    this._data = {};1157  }1158};1159 1160/**1161 * Transforms hyphen case variable into camel case.1162 *1163 * @param {String} string Hyphen case string1164 * @return {String} Camel case string1165 * @static1166 * @private1167 */1168exports.hyphenToCamel = function (str) {1169  return str.replace(/-[a-z]/g, function (match) { return match[1].toUpperCase(); });1170};1171 1172/**1173 * Returns a null-prototype object in runtimes that support it1174 *1175 * @return {Object} Object, prototype will be set to null where possible1176 * @static1177 * @private1178 */1179exports.createNullProtoObjWherePossible = (function () {1180  if (typeof Object.create == 'function') {1181    return function () {1182      return Object.create(null);1183    };1184  }1185  if (!({__proto__: null} instanceof Object)) {1186    return function () {1187      return {__proto__: null};1188    };1189  }1190  // Not possible, just pass through1191  return function () {1192    return {};1193  };1194})();1195 1196exports.hasOwnOnlyObject = function (obj) {1197  var o = exports.createNullProtoObjWherePossible();1198  for (var p in obj) {1199    if (hasOwn(obj, p)) {1200      o[p] = obj[p];

Showing the first 1,200 of 1747 lines. Download the file for the rest.

Brunobkr/llama.cpp_AlgMor24_github · Team Ai