index.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  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__(1682324647607, function(require, module, exports) {
  8. module.exports = Yallist
  9. Yallist.Node = Node
  10. Yallist.create = Yallist
  11. function Yallist (list) {
  12. var self = this
  13. if (!(self instanceof Yallist)) {
  14. self = new Yallist()
  15. }
  16. self.tail = null
  17. self.head = null
  18. self.length = 0
  19. if (list && typeof list.forEach === 'function') {
  20. list.forEach(function (item) {
  21. self.push(item)
  22. })
  23. } else if (arguments.length > 0) {
  24. for (var i = 0, l = arguments.length; i < l; i++) {
  25. self.push(arguments[i])
  26. }
  27. }
  28. return self
  29. }
  30. Yallist.prototype.removeNode = function (node) {
  31. if (node.list !== this) {
  32. throw new Error('removing node which does not belong to this list')
  33. }
  34. var next = node.next
  35. var prev = node.prev
  36. if (next) {
  37. next.prev = prev
  38. }
  39. if (prev) {
  40. prev.next = next
  41. }
  42. if (node === this.head) {
  43. this.head = next
  44. }
  45. if (node === this.tail) {
  46. this.tail = prev
  47. }
  48. node.list.length--
  49. node.next = null
  50. node.prev = null
  51. node.list = null
  52. return next
  53. }
  54. Yallist.prototype.unshiftNode = function (node) {
  55. if (node === this.head) {
  56. return
  57. }
  58. if (node.list) {
  59. node.list.removeNode(node)
  60. }
  61. var head = this.head
  62. node.list = this
  63. node.next = head
  64. if (head) {
  65. head.prev = node
  66. }
  67. this.head = node
  68. if (!this.tail) {
  69. this.tail = node
  70. }
  71. this.length++
  72. }
  73. Yallist.prototype.pushNode = function (node) {
  74. if (node === this.tail) {
  75. return
  76. }
  77. if (node.list) {
  78. node.list.removeNode(node)
  79. }
  80. var tail = this.tail
  81. node.list = this
  82. node.prev = tail
  83. if (tail) {
  84. tail.next = node
  85. }
  86. this.tail = node
  87. if (!this.head) {
  88. this.head = node
  89. }
  90. this.length++
  91. }
  92. Yallist.prototype.push = function () {
  93. for (var i = 0, l = arguments.length; i < l; i++) {
  94. push(this, arguments[i])
  95. }
  96. return this.length
  97. }
  98. Yallist.prototype.unshift = function () {
  99. for (var i = 0, l = arguments.length; i < l; i++) {
  100. unshift(this, arguments[i])
  101. }
  102. return this.length
  103. }
  104. Yallist.prototype.pop = function () {
  105. if (!this.tail) {
  106. return undefined
  107. }
  108. var res = this.tail.value
  109. this.tail = this.tail.prev
  110. if (this.tail) {
  111. this.tail.next = null
  112. } else {
  113. this.head = null
  114. }
  115. this.length--
  116. return res
  117. }
  118. Yallist.prototype.shift = function () {
  119. if (!this.head) {
  120. return undefined
  121. }
  122. var res = this.head.value
  123. this.head = this.head.next
  124. if (this.head) {
  125. this.head.prev = null
  126. } else {
  127. this.tail = null
  128. }
  129. this.length--
  130. return res
  131. }
  132. Yallist.prototype.forEach = function (fn, thisp) {
  133. thisp = thisp || this
  134. for (var walker = this.head, i = 0; walker !== null; i++) {
  135. fn.call(thisp, walker.value, i, this)
  136. walker = walker.next
  137. }
  138. }
  139. Yallist.prototype.forEachReverse = function (fn, thisp) {
  140. thisp = thisp || this
  141. for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
  142. fn.call(thisp, walker.value, i, this)
  143. walker = walker.prev
  144. }
  145. }
  146. Yallist.prototype.get = function (n) {
  147. for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
  148. // abort out of the list early if we hit a cycle
  149. walker = walker.next
  150. }
  151. if (i === n && walker !== null) {
  152. return walker.value
  153. }
  154. }
  155. Yallist.prototype.getReverse = function (n) {
  156. for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
  157. // abort out of the list early if we hit a cycle
  158. walker = walker.prev
  159. }
  160. if (i === n && walker !== null) {
  161. return walker.value
  162. }
  163. }
  164. Yallist.prototype.map = function (fn, thisp) {
  165. thisp = thisp || this
  166. var res = new Yallist()
  167. for (var walker = this.head; walker !== null;) {
  168. res.push(fn.call(thisp, walker.value, this))
  169. walker = walker.next
  170. }
  171. return res
  172. }
  173. Yallist.prototype.mapReverse = function (fn, thisp) {
  174. thisp = thisp || this
  175. var res = new Yallist()
  176. for (var walker = this.tail; walker !== null;) {
  177. res.push(fn.call(thisp, walker.value, this))
  178. walker = walker.prev
  179. }
  180. return res
  181. }
  182. Yallist.prototype.reduce = function (fn, initial) {
  183. var acc
  184. var walker = this.head
  185. if (arguments.length > 1) {
  186. acc = initial
  187. } else if (this.head) {
  188. walker = this.head.next
  189. acc = this.head.value
  190. } else {
  191. throw new TypeError('Reduce of empty list with no initial value')
  192. }
  193. for (var i = 0; walker !== null; i++) {
  194. acc = fn(acc, walker.value, i)
  195. walker = walker.next
  196. }
  197. return acc
  198. }
  199. Yallist.prototype.reduceReverse = function (fn, initial) {
  200. var acc
  201. var walker = this.tail
  202. if (arguments.length > 1) {
  203. acc = initial
  204. } else if (this.tail) {
  205. walker = this.tail.prev
  206. acc = this.tail.value
  207. } else {
  208. throw new TypeError('Reduce of empty list with no initial value')
  209. }
  210. for (var i = this.length - 1; walker !== null; i--) {
  211. acc = fn(acc, walker.value, i)
  212. walker = walker.prev
  213. }
  214. return acc
  215. }
  216. Yallist.prototype.toArray = function () {
  217. var arr = new Array(this.length)
  218. for (var i = 0, walker = this.head; walker !== null; i++) {
  219. arr[i] = walker.value
  220. walker = walker.next
  221. }
  222. return arr
  223. }
  224. Yallist.prototype.toArrayReverse = function () {
  225. var arr = new Array(this.length)
  226. for (var i = 0, walker = this.tail; walker !== null; i++) {
  227. arr[i] = walker.value
  228. walker = walker.prev
  229. }
  230. return arr
  231. }
  232. Yallist.prototype.slice = function (from, to) {
  233. to = to || this.length
  234. if (to < 0) {
  235. to += this.length
  236. }
  237. from = from || 0
  238. if (from < 0) {
  239. from += this.length
  240. }
  241. var ret = new Yallist()
  242. if (to < from || to < 0) {
  243. return ret
  244. }
  245. if (from < 0) {
  246. from = 0
  247. }
  248. if (to > this.length) {
  249. to = this.length
  250. }
  251. for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
  252. walker = walker.next
  253. }
  254. for (; walker !== null && i < to; i++, walker = walker.next) {
  255. ret.push(walker.value)
  256. }
  257. return ret
  258. }
  259. Yallist.prototype.sliceReverse = function (from, to) {
  260. to = to || this.length
  261. if (to < 0) {
  262. to += this.length
  263. }
  264. from = from || 0
  265. if (from < 0) {
  266. from += this.length
  267. }
  268. var ret = new Yallist()
  269. if (to < from || to < 0) {
  270. return ret
  271. }
  272. if (from < 0) {
  273. from = 0
  274. }
  275. if (to > this.length) {
  276. to = this.length
  277. }
  278. for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
  279. walker = walker.prev
  280. }
  281. for (; walker !== null && i > from; i--, walker = walker.prev) {
  282. ret.push(walker.value)
  283. }
  284. return ret
  285. }
  286. Yallist.prototype.splice = function (start, deleteCount, ...nodes) {
  287. if (start > this.length) {
  288. start = this.length - 1
  289. }
  290. if (start < 0) {
  291. start = this.length + start;
  292. }
  293. for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
  294. walker = walker.next
  295. }
  296. var ret = []
  297. for (var i = 0; walker && i < deleteCount; i++) {
  298. ret.push(walker.value)
  299. walker = this.removeNode(walker)
  300. }
  301. if (walker === null) {
  302. walker = this.tail
  303. }
  304. if (walker !== this.head && walker !== this.tail) {
  305. walker = walker.prev
  306. }
  307. for (var i = 0; i < nodes.length; i++) {
  308. walker = insert(this, walker, nodes[i])
  309. }
  310. return ret;
  311. }
  312. Yallist.prototype.reverse = function () {
  313. var head = this.head
  314. var tail = this.tail
  315. for (var walker = head; walker !== null; walker = walker.prev) {
  316. var p = walker.prev
  317. walker.prev = walker.next
  318. walker.next = p
  319. }
  320. this.head = tail
  321. this.tail = head
  322. return this
  323. }
  324. function insert (self, node, value) {
  325. var inserted = node === self.head ?
  326. new Node(value, null, node, self) :
  327. new Node(value, node, node.next, self)
  328. if (inserted.next === null) {
  329. self.tail = inserted
  330. }
  331. if (inserted.prev === null) {
  332. self.head = inserted
  333. }
  334. self.length++
  335. return inserted
  336. }
  337. function push (self, item) {
  338. self.tail = new Node(item, self.tail, null, self)
  339. if (!self.head) {
  340. self.head = self.tail
  341. }
  342. self.length++
  343. }
  344. function unshift (self, item) {
  345. self.head = new Node(item, null, self.head, self)
  346. if (!self.tail) {
  347. self.tail = self.head
  348. }
  349. self.length++
  350. }
  351. function Node (value, prev, next, list) {
  352. if (!(this instanceof Node)) {
  353. return new Node(value, prev, next, list)
  354. }
  355. this.list = list
  356. this.value = value
  357. if (prev) {
  358. prev.next = this
  359. this.prev = prev
  360. } else {
  361. this.prev = null
  362. }
  363. if (next) {
  364. next.prev = this
  365. this.next = next
  366. } else {
  367. this.next = null
  368. }
  369. }
  370. try {
  371. // add if support for Symbol.iterator is present
  372. require('./iterator.js')(Yallist)
  373. } catch (er) {}
  374. }, function(modId) {var map = {"./iterator.js":1682324647608}; return __REQUIRE__(map[modId], modId); })
  375. __DEFINE__(1682324647608, function(require, module, exports) {
  376. module.exports = function (Yallist) {
  377. Yallist.prototype[Symbol.iterator] = function* () {
  378. for (let walker = this.head; walker; walker = walker.next) {
  379. yield walker.value
  380. }
  381. }
  382. }
  383. }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
  384. return __REQUIRE__(1682324647607);
  385. })()
  386. //miniprogram-npm-outsideDeps=[]
  387. //# sourceMappingURL=index.js.map