Skip to content

Latest commit

 

History

History
54 lines (38 loc) · 3.87 KB

DIVERGENCES.md

File metadata and controls

54 lines (38 loc) · 3.87 KB

This document aims to list places where an API to address similar use cases is developed differently in different environments. These differences sometimes make it hard to write code which spans environments, and sometimes justify investigation into a shared solution.

This initial document includes Node and Web APIs, but PRs are welcome to document additional environments as well. Some of the entries here may be poor analogies--if so, please make a PR to clarify things!

For interfaces to be considered analogous, there should be some evidence that developers today are using them in a shared way today, e.g., a widely-used polyfill of one in terms of the other, or a widely-used higher-level API based on them both.

Event handling

  • Purpose: Register callbacks for certain events
  • Web API: EventTarget
  • Node.js API: EventEmitter
  • Mitigation strategies: TODO (Observables? Polyfills? How do programmers write isomorphic code today?)

Streams

Buffers

HTTP access

  • Purpose: Open, read and write to an HTTP, HTTPS, HTTP2 connection
  • Web API: fetch()
  • Node.js API: http, https, http2
  • Mitigation strategies: node-fetch polyfill to support fetch from Node.js, stream-http implementation of the Node HTTP module for browsers

Cryptography

  • Purpose: Basic cryptography algorithms, available as a standard library
  • Web API: WebCrypto's crypto.subtle SubtleCrypto
  • Node.js API: The crypto module
  • Mitigation strategies: npm packages like uuid detect where they are running and use whatever APIs are available. There are various WebCrypto polyfills/shims in npm, but none seem to be very widely used.

Filesystem access

  • Purpose: Read and write files on the filesystem
  • Web API: File API, in-progress WritableFile proposal
  • Node.js API: fs module
  • Mitigation strategies: TODO (Unclear if these are analogous enough to actually ever be bridged in practice)

Cancel[l]ation

  • Purpose: Provide APIs which cancel asynchronous processes, asynchronous requests, promises, etc.
  • Web API: AbortController
  • Node API: ??
  • Mitigation strategies: ??