PHP WebShell

Текущая директория: /opt/bitgo-express/node_modules/eol

Просмотр файла: test.js

!function(root) {
  function contains(str, needle) {
    return !!~str.indexOf(needle);
  }

  var common = typeof module != 'undefined' && !!module.exports
  var aok = common ? require('aok') : root.aok
  var eol = common ? require('./') : root.eol
  var isWindows = typeof process != 'undefined' && 'win32' === process.platform
  var meths = ['lf', 'cr', 'crlf', 'auto']
  var chars = ['\n', '\r', '\r\n', isWindows ? '\r\n' : '\n']
  var sample = ' ' + chars.join() + 'text' + chars.join()

  aok.prototype.fail = function() {
    throw new Error('FAILED TEST: ' + this.id)
  }

  aok('contains sees contained text', contains('ab', 'a') === true)
  aok('sample contains newlines', contains(sample, '\n') && contains(sample, '\r'))
  aok('returns other strings as is', eol.auto('random') === 'random')
  aok('returns empty strings as is', eol.auto('') === '')
  aok('whitespace intact', eol.lf(' \t ') === ' \t ')
  aok('lf repeat newlines intact', eol.lf('\n\n\r\r') === '\n\n\n\n')
  aok('cr repeat newlines intact', eol.cr('\n\n\r\r') === '\r\r\r\r')
  aok('crlf repeat newlines intact', eol.crlf('\r\n\r\n') === '\r\n\r\n')

  aok.pass(meths, function(method, i) {
    var normalized = eol[method](sample)
    aok(method + ' retains', contains(normalized, chars[i]))
    aok(method + ' normalizes', !aok.fail(chars, function(c) {
      return contains(chars[i], c) === contains(normalized, c)
    }))

    return eol.auto(sample) === normalized
  })

  aok('auto is aware', eol[isWindows ? 'crlf' : 'lf'](sample) === eol.auto(sample))
  aok('auto matches only 1 and self', aok.pass(meths, function(method) {
    return eol.auto(sample) === eol[method](sample);
  }) === 2)

  aok('before', eol.lf(eol.before('text')) === '\ntext')
  aok('before2', eol.lf(eol.before('\ntext\n')) === '\n\ntext\n')
  aok('after', eol.lf(eol.after('text')) === 'text\n')
  aok('after2', eol.lf(eol.after('\ntext\n')) === '\ntext\n\n')

  aok.log('All tests passed =)')
}(this);

Выполнить команду


Для локальной разработки. Не используйте в интернете!