Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

42 lignes
1.6 KiB

il y a 4 ans
  1. Browser-friendly inheritance fully compatible with standard node.js
  2. [inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor).
  3. This package exports standard `inherits` from node.js `util` module in
  4. node environment, but also provides alternative browser-friendly
  5. implementation through [browser
  6. field](https://gist.github.com/shtylman/4339901). Alternative
  7. implementation is a literal copy of standard one located in standalone
  8. module to avoid requiring of `util`. It also has a shim for old
  9. browsers with no `Object.create` support.
  10. While keeping you sure you are using standard `inherits`
  11. implementation in node.js environment, it allows bundlers such as
  12. [browserify](https://github.com/substack/node-browserify) to not
  13. include full `util` package to your client code if all you need is
  14. just `inherits` function. It worth, because browser shim for `util`
  15. package is large and `inherits` is often the single function you need
  16. from it.
  17. It's recommended to use this package instead of
  18. `require('util').inherits` for any code that has chances to be used
  19. not only in node.js but in browser too.
  20. ## usage
  21. ```js
  22. var inherits = require('inherits');
  23. // then use exactly as the standard one
  24. ```
  25. ## note on version ~1.0
  26. Version ~1.0 had completely different motivation and is not compatible
  27. neither with 2.0 nor with standard node.js `inherits`.
  28. If you are using version ~1.0 and planning to switch to ~2.0, be
  29. careful:
  30. * new version uses `super_` instead of `super` for referencing
  31. superclass
  32. * new version overwrites current prototype while old one preserves any
  33. existing fields on it