Comparing version 0.1.1 to 0.1.2
@@ -1,1 +0,1 @@ | ||
{"processes":{"d2b482b5-33e0-4311-a58c-42783d31f5af":{"parent":null,"children":[]}},"files":{},"externalIds":{}} | ||
{"processes":{"c7842a00-b67d-4e96-8df7-4c950b44e3e6":{"parent":null,"children":[]}},"files":{},"externalIds":{}} |
@@ -6,6 +6,14 @@ 'use strict'; | ||
var map = require('./map.js'); | ||
require('./string.js'); | ||
var environment = require('./environment.js'); | ||
var pair = require('./pair.js'); | ||
var error = require('./error.js'); | ||
/* istanbul ignore file */ | ||
const doc = /** @type {Document} */ (environment.isBrowser ? document : {}); | ||
const createElement = /** @type {function(string):HTMLElement} */ (environment.isBrowser ? doc.createElement.bind(doc) : error.unexpectedCase); | ||
const createDocumentFragment = /** @type {function():DocumentFragment} */ (environment.isBrowser ? doc.createDocumentFragment.bind(doc) : error.unexpectedCase); | ||
const createTextNode = /** @type {function(string):Text} */ (environment.isBrowser ? doc.createTextNode.bind(doc) : error.unexpectedCase); | ||
/** | ||
@@ -43,3 +51,3 @@ * @param {Element} el | ||
const fragment = children => { | ||
const fragment = document.createDocumentFragment(); | ||
const fragment = createDocumentFragment(); | ||
children.forEach(fragment.appendChild.bind(fragment)); | ||
@@ -100,3 +108,3 @@ return fragment | ||
const element = (name, attrs = [], children = []) => | ||
append(setAttributes(document.createElement(name), attrs), children); | ||
append(setAttributes(createElement(name), attrs), children); | ||
@@ -108,3 +116,3 @@ /** | ||
const canvas = (width, height) => { | ||
const c = document.createElement('canvas'); | ||
const c = /** @type {HTMLCanvasElement} */ (createElement('canvas')); | ||
c.height = height; | ||
@@ -119,3 +127,3 @@ c.width = width; | ||
*/ | ||
const text = t => document.createTextNode(t); | ||
const text = createTextNode; | ||
@@ -139,2 +147,24 @@ /** | ||
/** | ||
* @todo should always query on a dom element | ||
* | ||
* @param {Element} el | ||
* @param {string} query | ||
* @return {Element | null} | ||
*/ | ||
const querySelector = (el, query) => el.querySelector(query); | ||
/** | ||
* @param {Element} el | ||
* @param {string} query | ||
* @return {NodeListOf<Element>} | ||
*/ | ||
const querySelectorAll = (el, query) => el.querySelectorAll(query); | ||
/** | ||
* @param {string} id | ||
* @return {Element} | ||
*/ | ||
const getElementById = environment.isBrowser ? doc.getElementById.bind(doc) : error.unexpectedCase; | ||
exports.addEventListener = addEventListener; | ||
@@ -144,7 +174,11 @@ exports.addEventListeners = addEventListeners; | ||
exports.canvas = canvas; | ||
exports.doc = doc; | ||
exports.element = element; | ||
exports.fragment = fragment; | ||
exports.getElementById = getElementById; | ||
exports.mapToStyleString = mapToStyleString; | ||
exports.pairToStyleString = pairToStyleString; | ||
exports.pairsToStyleString = pairsToStyleString; | ||
exports.querySelector = querySelector; | ||
exports.querySelectorAll = querySelectorAll; | ||
exports.removeEventListener = removeEventListener; | ||
@@ -151,0 +185,0 @@ exports.removeEventListeners = removeEventListeners; |
@@ -13,2 +13,3 @@ 'use strict'; | ||
const isBrowser = typeof window !== 'undefined' && !isNode; | ||
const isMac = typeof navigator !== 'undefined' ? /Mac/.test(navigator.platform) : false; | ||
@@ -83,4 +84,5 @@ /** | ||
exports.isBrowser = isBrowser; | ||
exports.isMac = isMac; | ||
exports.isNode = isNode; | ||
exports.production = production; | ||
//# sourceMappingURL=environment.js.map |
@@ -9,2 +9,3 @@ 'use strict'; | ||
var pair = require('./pair.js'); | ||
require('./error.js'); | ||
var dom = require('./dom.js'); | ||
@@ -26,22 +27,3 @@ var math = require('./math.js'); | ||
/* istanbul ignore next */ | ||
class Style { | ||
/** | ||
* @param {string} text | ||
* @param {Array<pair.Pair<string,string>>} attrs | ||
*/ | ||
constructor (text, attrs) { | ||
this.text = text; | ||
this.attrs = attrs; | ||
} | ||
} | ||
/* istanbul ignore next */ | ||
/** | ||
* @param {string} text | ||
* @param {Array<pair.Pair<string,string>>} attrs | ||
*/ | ||
const style = (text, attrs) => new Style(text, attrs); | ||
/** | ||
* @type {Object<Symbol,pair.Pair<string,string>>} | ||
@@ -415,5 +397,4 @@ */ | ||
exports.printImgBase64 = printImgBase64; | ||
exports.style = style; | ||
exports.vconsoles = vconsoles; | ||
exports.warn = warn; | ||
//# sourceMappingURL=logging.js.map |
@@ -16,2 +16,3 @@ 'use strict'; | ||
const log = Math.log; | ||
const sqrt = Math.sqrt; | ||
@@ -56,2 +57,3 @@ /** | ||
exports.round = round; | ||
exports.sqrt = sqrt; | ||
//# sourceMappingURL=math.js.map |
@@ -11,2 +11,7 @@ 'use strict'; | ||
/** | ||
* Object.assign | ||
*/ | ||
const assign = Object.assign; | ||
/** | ||
* @param {Object<string,any>} obj | ||
@@ -81,2 +86,3 @@ */ | ||
exports.assign = assign; | ||
exports.create = create; | ||
@@ -83,0 +89,0 @@ exports.equalFlat = equalFlat; |
@@ -62,2 +62,4 @@ 'use strict'; | ||
* | ||
* @todo This should catch exceptions | ||
* | ||
* @param {N} name The event name. | ||
@@ -64,0 +66,0 @@ * @param {Array} args The arguments that are applied to the event listener. |
@@ -13,2 +13,3 @@ 'use strict'; | ||
require('./pair.js'); | ||
require('./error.js'); | ||
require('./dom.js'); | ||
@@ -15,0 +16,0 @@ var math = require('./math.js'); |
37
dom.js
/* istanbul ignore file */ | ||
import * as pair from './pair.js' | ||
import * as map from './map.js' | ||
import * as environment from './environment.js' | ||
import * as error from './error.js' | ||
export const doc = /** @type {Document} */ (environment.isBrowser ? document : {}) | ||
const createElement = /** @type {function(string):HTMLElement} */ (environment.isBrowser ? doc.createElement.bind(doc) : error.unexpectedCase) | ||
const createDocumentFragment = /** @type {function():DocumentFragment} */ (environment.isBrowser ? doc.createDocumentFragment.bind(doc) : error.unexpectedCase) | ||
const createTextNode = /** @type {function(string):Text} */ (environment.isBrowser ? doc.createTextNode.bind(doc) : error.unexpectedCase) | ||
/** | ||
@@ -37,3 +44,3 @@ * @param {Element} el | ||
export const fragment = children => { | ||
const fragment = document.createDocumentFragment() | ||
const fragment = createDocumentFragment() | ||
children.forEach(fragment.appendChild.bind(fragment)) | ||
@@ -94,3 +101,3 @@ return fragment | ||
export const element = (name, attrs = [], children = []) => | ||
append(setAttributes(document.createElement(name), attrs), children) | ||
append(setAttributes(createElement(name), attrs), children) | ||
@@ -102,3 +109,3 @@ /** | ||
export const canvas = (width, height) => { | ||
const c = document.createElement('canvas') | ||
const c = /** @type {HTMLCanvasElement} */ (createElement('canvas')) | ||
c.height = height | ||
@@ -113,3 +120,3 @@ c.width = width | ||
*/ | ||
export const text = t => document.createTextNode(t) | ||
export const text = createTextNode | ||
@@ -132,1 +139,23 @@ /** | ||
export const mapToStyleString = m => map.map(m, (value, key) => `${key}:${value};`).join('') | ||
/** | ||
* @todo should always query on a dom element | ||
* | ||
* @param {Element} el | ||
* @param {string} query | ||
* @return {Element | null} | ||
*/ | ||
export const querySelector = (el, query) => el.querySelector(query) | ||
/** | ||
* @param {Element} el | ||
* @param {string} query | ||
* @return {NodeListOf<Element>} | ||
*/ | ||
export const querySelectorAll = (el, query) => el.querySelectorAll(query) | ||
/** | ||
* @param {string} id | ||
* @return {Element} | ||
*/ | ||
export const getElementById = environment.isBrowser ? doc.getElementById.bind(doc) : error.unexpectedCase |
@@ -10,2 +10,3 @@ | ||
export const isBrowser = typeof window !== 'undefined' && !isNode | ||
export const isMac = typeof navigator !== 'undefined' ? /Mac/.test(navigator.platform) : false | ||
@@ -12,0 +13,0 @@ /** |
@@ -21,22 +21,3 @@ | ||
/* istanbul ignore next */ | ||
class Style { | ||
/** | ||
* @param {string} text | ||
* @param {Array<pair.Pair<string,string>>} attrs | ||
*/ | ||
constructor (text, attrs) { | ||
this.text = text | ||
this.attrs = attrs | ||
} | ||
} | ||
/* istanbul ignore next */ | ||
/** | ||
* @param {string} text | ||
* @param {Array<pair.Pair<string,string>>} attrs | ||
*/ | ||
export const style = (text, attrs) => new Style(text, attrs) | ||
/** | ||
* @type {Object<Symbol,pair.Pair<string,string>>} | ||
@@ -43,0 +24,0 @@ */ |
@@ -12,2 +12,3 @@ /** | ||
export const log = Math.log | ||
export const sqrt = Math.sqrt | ||
@@ -14,0 +15,0 @@ /** |
@@ -8,2 +8,7 @@ | ||
/** | ||
* Object.assign | ||
*/ | ||
export const assign = Object.assign | ||
/** | ||
* @param {Object<string,any>} obj | ||
@@ -10,0 +15,0 @@ */ |
@@ -59,2 +59,4 @@ | ||
* | ||
* @todo This should catch exceptions | ||
* | ||
* @param {N} name The event name. | ||
@@ -61,0 +63,0 @@ * @param {Array} args The arguments that are applied to the event listener. |
{ | ||
"name": "lib0", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "dependencies": {}, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
843957
12214