Adding mapbox-gl branch

This commit is contained in:
Andreas Hocevar
2015-03-16 18:50:27 +01:00
parent 7985f030fa
commit 57ee7f52fd
3109 changed files with 943365 additions and 0 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<!--
Copyright 2013 The Closure Library Authors. All Rights Reserved.
Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<head>
<title>Closure Unit Tests - goog.Promise</title>
<script src="../base.js"></script>
<script>
goog.require('goog.PromiseTest');
</script>
</head>
<body>
</body>
</html>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,48 @@
// Copyright 2013 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
goog.provide('goog.promise.Resolver');
/**
* Resolver interface for promises. The resolver is a convenience interface that
* bundles the promise and its associated resolve and reject functions together,
* for cases where the resolver needs to be persisted internally.
*
* @interface
* @template TYPE
*/
goog.promise.Resolver = function() {};
/**
* The promise that created this resolver.
* @type {!goog.Promise<TYPE>}
*/
goog.promise.Resolver.prototype.promise;
/**
* Resolves this resolver with the specified value.
* @type {function((TYPE|goog.Promise<TYPE>|Thenable)=)}
*/
goog.promise.Resolver.prototype.resolve;
/**
* Rejects this resolver with the specified reason.
* @type {function(*): void}
*/
goog.promise.Resolver.prototype.reject;
@@ -0,0 +1,74 @@
// Copyright 2013 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @fileoverview Test adapter for testing Closure Promises against the
* Promises/A+ Compliance Test Suite, which is implemented as a Node.js module.
*
* This test suite adapter may not be run in Node.js directly, but must first be
* compiled with the Closure Compiler to pull in the required dependencies.
*
* @see https://npmjs.org/package/promises-aplus-tests
*/
goog.provide('goog.promise.testSuiteAdapter');
goog.require('goog.Promise');
goog.setTestOnly('goog.promise.testSuiteAdapter');
var promisesAplusTests = /** @type {function(!Object, function(*))} */ (
require('promises_aplus_tests'));
/**
* Adapter for specifying Promise-creating functions to the Promises test suite.
* @type {!Object}
*/
goog.promise.testSuiteAdapter = {
/** @type {function(*): !goog.Promise} */
'resolved': goog.Promise.resolve,
/** @type {function(*): !goog.Promise} */
'rejected': goog.Promise.reject,
/** @return {!Object} */
'deferred': function() {
var promiseObj = {};
promiseObj['promise'] = new goog.Promise(function(resolve, reject) {
promiseObj['resolve'] = resolve;
promiseObj['reject'] = reject;
});
return promiseObj;
}
};
// Node.js defines setTimeout globally, but Closure relies on finding it
// defined on goog.global.
goog.exportSymbol('setTimeout', setTimeout);
// Rethrowing an error to the global scope kills Node immediately. Suppress
// error rethrowing for running this test suite.
goog.Promise.setUnhandledRejectionHandler(goog.nullFunction);
// Run the tests, exiting with a failure code if any of the tests fail.
promisesAplusTests(goog.promise.testSuiteAdapter, function(err) {
if (err) {
process.exit(1);
}
});
@@ -0,0 +1,111 @@
// Copyright 2013 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
goog.provide('goog.Thenable');
/**
* Provides a more strict interface for Thenables in terms of
* http://promisesaplus.com for interop with {@see goog.Promise}.
*
* @interface
* @extends {IThenable<TYPE>}
* @template TYPE
*/
goog.Thenable = function() {};
/**
* Adds callbacks that will operate on the result of the Thenable, returning a
* new child Promise.
*
* If the Thenable is fulfilled, the {@code onFulfilled} callback will be
* invoked with the fulfillment value as argument, and the child Promise will
* be fulfilled with the return value of the callback. If the callback throws
* an exception, the child Promise will be rejected with the thrown value
* instead.
*
* If the Thenable is rejected, the {@code onRejected} callback will be invoked
* with the rejection reason as argument, and the child Promise will be rejected
* with the return value of the callback or thrown value.
*
* @param {?(function(this:THIS, TYPE):
* (RESULT|IThenable<RESULT>|Thenable))=} opt_onFulfilled A
* function that will be invoked with the fulfillment value if the Promise
* is fullfilled.
* @param {?(function(this:THIS, *): *)=} opt_onRejected A function that will
* be invoked with the rejection reason if the Promise is rejected.
* @param {THIS=} opt_context An optional context object that will be the
* execution context for the callbacks. By default, functions are executed
* with the default this.
* @return {!goog.Promise<RESULT>} A new Promise that will receive the result
* of the fulfillment or rejection callback.
* @template RESULT,THIS
*/
goog.Thenable.prototype.then = function(opt_onFulfilled, opt_onRejected,
opt_context) {};
/**
* An expando property to indicate that an object implements
* {@code goog.Thenable}.
*
* {@see addImplementation}.
*
* @const
*/
goog.Thenable.IMPLEMENTED_BY_PROP = '$goog_Thenable';
/**
* Marks a given class (constructor) as an implementation of Thenable, so
* that we can query that fact at runtime. The class must have already
* implemented the interface.
* Exports a 'then' method on the constructor prototype, so that the objects
* also implement the extern {@see goog.Thenable} interface for interop with
* other Promise implementations.
* @param {function(new:goog.Thenable,...?)} ctor The class constructor. The
* corresponding class must have already implemented the interface.
*/
goog.Thenable.addImplementation = function(ctor) {
goog.exportProperty(ctor.prototype, 'then', ctor.prototype.then);
if (COMPILED) {
ctor.prototype[goog.Thenable.IMPLEMENTED_BY_PROP] = true;
} else {
// Avoids dictionary access in uncompiled mode.
ctor.prototype.$goog_Thenable = true;
}
};
/**
* @param {*} object
* @return {boolean} Whether a given instance implements {@code goog.Thenable}.
* The class/superclass of the instance must call {@code addImplementation}.
*/
goog.Thenable.isImplementedBy = function(object) {
if (!object) {
return false;
}
try {
if (COMPILED) {
return !!object[goog.Thenable.IMPLEMENTED_BY_PROP];
}
return !!object.$goog_Thenable;
} catch (e) {
// Property access seems to be forbidden.
return false;
}
};