MCPcopy
hub / github.com/ajv-validator/ajv / forIn

Method forIn

lib/compile/codegen/index.ts:637–648  ·  view source on GitHub ↗
(
    nameOrPrefix: Name | string,
    obj: Code,
    forBody: (item: Name) => void,
    varKind: Code = this.opts.es5 ? varKinds.var : varKinds.const
  )

Source from the content-addressed store, hash-verified

635 // `for-in` statement.
636 // With option `ownProperties` replaced with a `for-of` loop for object keys
637 forIn(
638 nameOrPrefix: Name | string,
639 obj: Code,
640 forBody: (item: Name) => void,
641 varKind: Code = this.opts.es5 ? varKinds.var : varKinds.const
642 ): CodeGen {
643 if (this.opts.ownProperties) {
644 return this.forOf(nameOrPrefix, _`Object.keys(${obj})`, forBody)
645 }
646 const name = this._scope.toName(nameOrPrefix)
647 return this._for(new ForIter("in", varKind, name, obj), () => forBody(name))
648 }
649
650 // end `for` loop
651 endFor(): CodeGen {

Callers 9

codeFunction · 0.80
validatePropertiesFunction · 0.80
codeFunction · 0.80
validateAdditionalFunction · 0.80
validateValuesFunction · 0.80
serializeValuesFunction · 0.80
codegen.spec.tsFile · 0.80

Calls 4

forOfMethod · 0.95
_forMethod · 0.95
_Function · 0.90
toNameMethod · 0.80

Tested by

no test coverage detected