|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
791 bytes
|
| Line | |
|---|
| 1 | import { VERSION } from './_setup.js';
|
|---|
| 2 |
|
|---|
| 3 | // If Underscore is called as a function, it returns a wrapped object that can
|
|---|
| 4 | // be used OO-style. This wrapper holds altered versions of all functions added
|
|---|
| 5 | // through `_.mixin`. Wrapped objects may be chained.
|
|---|
| 6 | export default function _(obj) {
|
|---|
| 7 | if (obj instanceof _) return obj;
|
|---|
| 8 | if (!(this instanceof _)) return new _(obj);
|
|---|
| 9 | this._wrapped = obj;
|
|---|
| 10 | }
|
|---|
| 11 |
|
|---|
| 12 | _.VERSION = VERSION;
|
|---|
| 13 |
|
|---|
| 14 | // Extracts the result from a wrapped and chained object.
|
|---|
| 15 | _.prototype.value = function() {
|
|---|
| 16 | return this._wrapped;
|
|---|
| 17 | };
|
|---|
| 18 |
|
|---|
| 19 | // Provide unwrapping proxies for some methods used in engine operations
|
|---|
| 20 | // such as arithmetic and JSON stringification.
|
|---|
| 21 | _.prototype.valueOf = _.prototype.toJSON = _.prototype.value;
|
|---|
| 22 |
|
|---|
| 23 | _.prototype.toString = function() {
|
|---|
| 24 | return String(this._wrapped);
|
|---|
| 25 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.