Get rid of olx.js and typedef.js typedefs for ol

This commit is contained in:
Andreas Hocevar
2018-03-08 18:42:57 +01:00
parent 8f0ffe2043
commit 95d6251dbb
198 changed files with 2262 additions and 2698 deletions
+21 -11
View File
@@ -5,6 +5,16 @@ import {assert} from './asserts.js';
import {clamp} from './math.js';
/**
* A color represented as a short array [red, green, blue, alpha].
* red, green, and blue should be integers in the range 0..255 inclusive.
* alpha should be a float in the range 0..1 inclusive. If no alpha value is
* given then `1` will be used.
* @typedef {Array.<number>} Color
* @api
*/
/**
* This RegExp matches # followed by 3, 4, 6, or 8 hex digits.
* @const
@@ -25,7 +35,7 @@ const NAMED_COLOR_RE_ = /^([a-z]*)$/i;
/**
* Return the color as an rgba string.
* @param {ol.Color|string} color Color.
* @param {module:ol/color~Color|string} color Color.
* @return {string} Rgba string.
* @api
*/
@@ -58,7 +68,7 @@ function fromNamed(color) {
/**
* @param {string} s String.
* @return {ol.Color} Color.
* @return {module:ol/color~Color} Color.
*/
export const fromString = (
function() {
@@ -74,7 +84,7 @@ export const fromString = (
const MAX_CACHE_SIZE = 1024;
/**
* @type {Object.<string, ol.Color>}
* @type {Object.<string, module:ol/color~Color>}
*/
const cache = {};
@@ -86,7 +96,7 @@ export const fromString = (
return (
/**
* @param {string} s String.
* @return {ol.Color} Color.
* @return {module:ol/color~Color} Color.
*/
function(s) {
let color;
@@ -115,8 +125,8 @@ export const fromString = (
/**
* Return the color as an array. This function maintains a cache of calculated
* arrays which means the result should not be modified.
* @param {ol.Color|string} color Color.
* @return {ol.Color} Color.
* @param {module:ol/color~Color|string} color Color.
* @return {module:ol/color~Color} Color.
* @api
*/
export function asArray(color) {
@@ -130,7 +140,7 @@ export function asArray(color) {
/**
* @param {string} s String.
* @private
* @return {ol.Color} Color.
* @return {module:ol/color~Color} Color.
*/
function fromStringInternal_(s) {
let r, g, b, a, color;
@@ -175,14 +185,14 @@ function fromStringInternal_(s) {
} else {
assert(false, 14); // Invalid color
}
return /** @type {ol.Color} */ (color);
return /** @type {module:ol/color~Color} */ (color);
}
/**
* TODO this function is only used in the test, we probably shouldn't export it
* @param {ol.Color} color Color.
* @return {ol.Color} Clamped color.
* @param {module:ol/color~Color} color Color.
* @return {module:ol/color~Color} Clamped color.
*/
export function normalize(color) {
color[0] = clamp((color[0] + 0.5) | 0, 0, 255);
@@ -194,7 +204,7 @@ export function normalize(color) {
/**
* @param {ol.Color} color Color.
* @param {module:ol/color~Color} color Color.
* @return {string} String.
*/
export function toString(color) {