No Description

underscore.js 791B

12345678910111213141516171819202122232425
  1. import { VERSION } from './_setup.js';
  2. // If Underscore is called as a function, it returns a wrapped object that can
  3. // be used OO-style. This wrapper holds altered versions of all functions added
  4. // through `_.mixin`. Wrapped objects may be chained.
  5. export default function _(obj) {
  6. if (obj instanceof _) return obj;
  7. if (!(this instanceof _)) return new _(obj);
  8. this._wrapped = obj;
  9. }
  10. _.VERSION = VERSION;
  11. // Extracts the result from a wrapped and chained object.
  12. _.prototype.value = function() {
  13. return this._wrapped;
  14. };
  15. // Provide unwrapping proxies for some methods used in engine operations
  16. // such as arithmetic and JSON stringification.
  17. _.prototype.valueOf = _.prototype.toJSON = _.prototype.value;
  18. _.prototype.toString = function() {
  19. return String(this._wrapped);
  20. };