MCPcopy
hub / github.com/tinyhttp/tinyhttp / wrapmethods

Function wrapmethods

packages/session/src/index.ts:486–515  ·  view source on GitHub ↗
(sess: Session)

Source from the content-addressed store, hash-verified

484
485 // wrap session methods
486 function wrapmethods(sess: Session) {
487 const _reload = sess.reload
488 const _save = sess.save
489
490 function reload(this: Session, callback: (args?: any) => void, ...args: any[]) {
491 _reload.call(this, function () {
492 wrapmethods(session as Session)
493 callback(args)
494 })
495 }
496
497 function save(this: Session, cb?: (err?: any) => void) {
498 savedHash = hash(this)
499 _save.apply(this, [cb])
500 }
501
502 Object.defineProperty(sess, 'reload', {
503 configurable: true,
504 enumerable: false,
505 value: reload,
506 writable: true
507 })
508
509 Object.defineProperty(sess, 'save', {
510 configurable: true,
511 enumerable: false,
512 value: save,
513 writable: true
514 })
515 }
516
517 // generate a session if the browser doesn't send a sessionID
518 if (!cookieId) {

Callers 3

generateFunction · 0.85
inflateFunction · 0.85
reloadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected