iterating.js 788 B

12345678910111213141516171819202122232425262728293031323334353637
  1. Types.Iterator = Ins (
  2. ES.Iterable, ES.Object,
  3. $(x => typeof x.next == 'function')
  4. )
  5. Types.AsyncIterator = Ins (
  6. ES.AsyncIterable,
  7. $(x => typeof x.next == 'function')
  8. )
  9. Types.EntryList = create_schema('EntryList', {
  10. keys: Types.List,
  11. values: Types.List
  12. }, {}, [], { guard: fun (
  13. 'function struct_guard (fields: Hash) -> Void',
  14. fields => {
  15. let ok = (fields.keys.length == fields.values.length)
  16. ensure(ok, 'bad_entry_list')
  17. return Void
  18. }
  19. )})
  20. Types.Iterable = Uni (
  21. ES.Iterable, Types.Enum,
  22. Types.Operand.inflate('iter')
  23. )
  24. Types.AsyncIterable = Uni (
  25. ES.AsyncIterable,
  26. Types.Operand.inflate('async_iter')
  27. )
  28. Types.Enumerable = Uni (
  29. Types.Hash, Types.Struct, Types.Enum,
  30. Types.Operand.inflate('enum')
  31. )