2022-07-24 19:52:05 +00:00
|
|
|
/* Returns true if set is a subset of the keys of obj */
|
|
|
|
export function subsetOfKeys(set, obj) {
|
|
|
|
for (const e of set) {
|
|
|
|
if (!(e in obj)) return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2022-08-05 12:48:57 +00:00
|
|
|
/* Returns a list of the types mentioned in a typed-function signature */
|
|
|
|
export function typeListOfSignature(signature) {
|
2022-08-30 19:36:44 +00:00
|
|
|
signature = signature.trim()
|
|
|
|
if (!signature) return []
|
2022-08-05 12:48:57 +00:00
|
|
|
return signature.split(',').map(s => s.trim())
|
|
|
|
}
|
|
|
|
|
2022-07-24 19:52:05 +00:00
|
|
|
/* Returns a set of all of the types mentioned in a typed-function signature */
|
|
|
|
export function typesOfSignature(signature) {
|
|
|
|
return new Set(signature.split(/[^\w\d]/).filter(s => s.length))
|
|
|
|
}
|