MCPcopy Create free account
hub / github.com/Y80/bmm / onData

Function onData

scripts/reset-user-password.mjs:74–101  ·  view source on GitHub ↗
(chunk)

Source from the content-addressed store, hash-verified

72 }
73
74 function onData(chunk) {
75 for (const value of Array.from(chunk.toString('utf8'))) {
76 if (value === '\u0003') {
77 cleanup()
78 reject(new Error('操作已取消'))
79 return
80 }
81
82 if (value === '\r' || value === '\n') {
83 cleanup()
84 resolve(password)
85 return
86 }
87
88 if (value === '\u007f') {
89 if (password.length > 0) {
90 password = password.slice(0, -1)
91 stdout.write('\b \b')
92 }
93 continue
94 }
95
96 if (value >= ' ') {
97 password += value
98 stdout.write('*')
99 }
100 }
101 }
102
103 stdout.write(`${message}: `)
104 stdin.resume()

Callers

nothing calls this directly

Calls 1

cleanupFunction · 0.70

Tested by

no test coverage detected