Skip to content

Commit

Permalink
Merge branch 'add-channels-message-type' of https://github.com/su-cha…
Browse files Browse the repository at this point in the history
…ng/wechaty-puppet into add-channels-message-type
  • Loading branch information
su-chang committed Sep 1, 2021
2 parents 05b2dd3 + b57f05f commit 5be9350
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/puppet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export abstract class Puppet extends PuppetEventEmitter {
*/

/**
* Need to be called internaly when the puppet is logined.
* Need to be called internally when the puppet is logined.
* this method will emit a `login` event
*/
protected async login (userId: string): Promise<void> {
Expand All @@ -383,7 +383,7 @@ export abstract class Puppet extends PuppetEventEmitter {
}

/**
* Need to be called internaly/externaly when the puppet need to be logouted
* Need to be called internally/externally when the puppet need to be logouted
* this method will emit a `logout` event,
*
* Note: must set `this.id = undefined` in this function.
Expand Down Expand Up @@ -578,7 +578,7 @@ export abstract class Puppet extends PuppetEventEmitter {
)
}

const filterFuncion: ContactPayloadFilterFunction = this.contactQueryFilterFactory(query)
const filterFunction: ContactPayloadFilterFunction = this.contactQueryFilterFactory(query)

const BATCH_SIZE = 16
let batchIndex = 0
Expand All @@ -594,7 +594,7 @@ export abstract class Puppet extends PuppetEventEmitter {
// const payload = await this.contactRawPayloadParser(rawPayload)
const payload = await this.contactPayload(id)

if (filterFuncion(payload)) {
if (filterFunction(payload)) {
return id
}

Expand Down Expand Up @@ -645,7 +645,7 @@ export abstract class Puppet extends PuppetEventEmitter {
if (Object.keys(query).length < 1) {
throw new Error('query must provide at least one key. current query is empty.')
} else if (Object.keys(query).length > 1) {
throw new Error('query only support one key. multi key support is not availble now.')
throw new Error('query only support one key. multi key support is not available now.')
}
// Huan(202105): we use `!` at here because the above `if` checks
const filterKey = Object.keys(query)[0]!.toLowerCase() as keyof ContactQueryFilter
Expand Down Expand Up @@ -674,7 +674,7 @@ export abstract class Puppet extends PuppetEventEmitter {
} else if (filterValue instanceof RegExp) {
filterFunction = (payload: ContactPayload) => !!payload[filterKey] && filterValue.test(payload[filterKey]!)
} else {
throw new Error('unsupport filterValue type: ' + typeof filterValue)
throw new Error('unsupported filterValue type: ' + typeof filterValue)
}

return filterFunction
Expand Down Expand Up @@ -1205,7 +1205,7 @@ export abstract class Puppet extends PuppetEventEmitter {
if (Object.keys(query).length < 1) {
throw new Error('query must provide at least one key. current query is empty.')
} else if (Object.keys(query).length > 1) {
throw new Error('query only support one key. multi key support is not availble now.')
throw new Error('query only support one key. multi key support is not available now.')
}
// Huan(202105): we use `Object.keys(query)[0]!` with `!` at here because we have the above `if` checks
// TypeScript bug: have to set `undefined | string | RegExp` at here, or the later code type check will get error
Expand Down

0 comments on commit 5be9350

Please sign in to comment.