index.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. module.exports = (function() {
  2. var __MODS__ = {};
  3. var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
  4. var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
  5. var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
  6. var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
  7. __DEFINE__(1682324647584, function(require, module, exports) {
  8. /*
  9. Copyright (c) 2014-2018, Matteo Collina <hello@matteocollina.com>
  10. Permission to use, copy, modify, and/or distribute this software for any
  11. purpose with or without fee is hereby granted, provided that the above
  12. copyright notice and this permission notice appear in all copies.
  13. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  14. WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  15. MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  16. ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  17. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  18. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
  19. IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. const { Transform } = require('readable-stream')
  22. const { StringDecoder } = require('string_decoder')
  23. const kLast = Symbol('last')
  24. const kDecoder = Symbol('decoder')
  25. function transform (chunk, enc, cb) {
  26. var list
  27. if (this.overflow) { // Line buffer is full. Skip to start of next line.
  28. var buf = this[kDecoder].write(chunk)
  29. list = buf.split(this.matcher)
  30. if (list.length === 1) return cb() // Line ending not found. Discard entire chunk.
  31. // Line ending found. Discard trailing fragment of previous line and reset overflow state.
  32. list.shift()
  33. this.overflow = false
  34. } else {
  35. this[kLast] += this[kDecoder].write(chunk)
  36. list = this[kLast].split(this.matcher)
  37. }
  38. this[kLast] = list.pop()
  39. for (var i = 0; i < list.length; i++) {
  40. try {
  41. push(this, this.mapper(list[i]))
  42. } catch (error) {
  43. return cb(error)
  44. }
  45. }
  46. this.overflow = this[kLast].length > this.maxLength
  47. if (this.overflow && !this.skipOverflow) return cb(new Error('maximum buffer reached'))
  48. cb()
  49. }
  50. function flush (cb) {
  51. // forward any gibberish left in there
  52. this[kLast] += this[kDecoder].end()
  53. if (this[kLast]) {
  54. try {
  55. push(this, this.mapper(this[kLast]))
  56. } catch (error) {
  57. return cb(error)
  58. }
  59. }
  60. cb()
  61. }
  62. function push (self, val) {
  63. if (val !== undefined) {
  64. self.push(val)
  65. }
  66. }
  67. function noop (incoming) {
  68. return incoming
  69. }
  70. function split (matcher, mapper, options) {
  71. // Set defaults for any arguments not supplied.
  72. matcher = matcher || /\r?\n/
  73. mapper = mapper || noop
  74. options = options || {}
  75. // Test arguments explicitly.
  76. switch (arguments.length) {
  77. case 1:
  78. // If mapper is only argument.
  79. if (typeof matcher === 'function') {
  80. mapper = matcher
  81. matcher = /\r?\n/
  82. // If options is only argument.
  83. } else if (typeof matcher === 'object' && !(matcher instanceof RegExp)) {
  84. options = matcher
  85. matcher = /\r?\n/
  86. }
  87. break
  88. case 2:
  89. // If mapper and options are arguments.
  90. if (typeof matcher === 'function') {
  91. options = mapper
  92. mapper = matcher
  93. matcher = /\r?\n/
  94. // If matcher and options are arguments.
  95. } else if (typeof mapper === 'object') {
  96. options = mapper
  97. mapper = noop
  98. }
  99. }
  100. options = Object.assign({}, options)
  101. options.transform = transform
  102. options.flush = flush
  103. options.readableObjectMode = true
  104. const stream = new Transform(options)
  105. stream[kLast] = ''
  106. stream[kDecoder] = new StringDecoder('utf8')
  107. stream.matcher = matcher
  108. stream.mapper = mapper
  109. stream.maxLength = options.maxLength
  110. stream.skipOverflow = options.skipOverflow
  111. stream.overflow = false
  112. return stream
  113. }
  114. module.exports = split
  115. }, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); })
  116. return __REQUIRE__(1682324647584);
  117. })()
  118. //miniprogram-npm-outsideDeps=["readable-stream","string_decoder"]
  119. //# sourceMappingURL=index.js.map