Home Manual Reference Source Test

Function

Static Public Summary
public

$(selector: string, context: Element | Document | DocumentFragment): Element[]

jQuery-like selector

public

Iteratable decorator for Class, Method or Getter

public

at(selector: String): Function

public

blobFrom(URI: String): Blob

public

async blobOf(URI: String): Promise<Blob>

public

Decorator for Property getter which returns Data URI

public

bodyOf(XHR: XMLHttpRequest): String | Document | DocumentFragment | Object | Blob

public
public

classNameOf(object: *): string

public
public

Register a component

public
public
public

decoratorOf(target: Function | Object, key: String, value: Function | Object | *, descriptor: Object): DecoratorDescriptor

public

delay(second: number): Promise

public

delegate(selector: String, handler: EventHandler): Function

DOM event delegate

public
public
public
public

extend(target: Object, source: ...Object): Object

Merge own properties of two or more objects together into the first object by their descriptor

public

fetch(URI: String | URL, request: Object): Promise<XMLHttpRequest>

Enhanced fetch() with Progress handlers based on XMLHttpRequest()

public

async fileTypeOf(URI: String): Object

public

getPropertyDescriptor(object: *, key: string): Object

public

indexOf(node: Node, inNodes: Boolean): Number

public

insertTo(parent: ParentNode, child: Node | String, position: Number | Node, inNodes: Boolean)

public

insertableIndexOf(list: Node[], index: Number): Number

public

isXDomain(URI: string | URL): boolean

public

likeArray(object: *): Boolean

public

async loadDOM(tree: Node, base: String): Node

public

loadModule(URI: String | URL, ESM: Boolean): Promise<Event>

public
public

Decorator for attributeChangedCallback() method

public

Decorator for observedAttributes getter

public

* mapTree(node: Object, fork_key: String)

Traverse Object-tree

public

mediaReady(context: Element | Document): Promise

public

multipleMap(list: Iterable, filter: function(item: *, index: number, list: Iterable): *): Array

Equivalent to the integration of Array's map() & filter() methods

public

on(type: String, selector: String): Function

public
public

parseHash(keyChar: String, valueChar: String, raw: String, mapper: function(key: String, value: String): Array): Object

public
public

readAs(file: File, type: String, encoding: String): String | ArrayBuffer

public

async request(URI: string, method: string, body: String | Object | Node, headers: Object, option: Object): Object

HTTP request

public

serialize(form: Element): String | FormData | Object

public
public

toDataURI(raw: String, type: String): String

public

toIterable(arrayLike: Object): Iterable

public

trigger(element: Element, event: String | Event, detail: *, bubbles: Boolean, cancelable: Boolean, composed: Boolean): Boolean

public

unique(list: Array, condition: String | Symbol | UniqueComparer): Array

public

watchAttributes(element: Element, names: string[], callback: AttributeWatcher): MutationObserver

Static Public

public $(selector: string, context: Element | Document | DocumentFragment): Element[] source

jQuery-like selector

Params:

NameTypeAttributeDescription
selector string
context Element | Document | DocumentFragment
  • optional
  • default: document

Return:

Element[]

Test:

public arrayLike(meta: DecoratorDescriptor) source

import {arrayLike} from 'web-cell/source/utility/object.js'

Iteratable decorator for Class, Method or Getter

Params:

NameTypeAttributeDescription
meta DecoratorDescriptor

Test:

public at(selector: String): Function source

Params:

NameTypeAttributeDescription
selector String

CSS selector

Return:

Function

Decorator for Event handler

public blobFrom(URI: String): Blob source

import {blobFrom} from 'web-cell/source/utility/resource.js'

Params:

NameTypeAttributeDescription
URI String

Data URI

Return:

Blob

Test:

public async blobOf(URI: String): Promise<Blob> source

Params:

NameTypeAttributeDescription
URI String

Returned by URL.createObjectURL()

Return:

Promise<Blob>

public blobURI(meta: DecoratorDescriptor) source

Decorator for Property getter which returns Data URI

Params:

NameTypeAttributeDescription
meta DecoratorDescriptor

public bodyOf(XHR: XMLHttpRequest): String | Document | DocumentFragment | Object | Blob source

import {bodyOf} from 'web-cell/source/utility/HTTP.js'

Params:

NameTypeAttributeDescription
XHR XMLHttpRequest

Return:

String | Document | DocumentFragment | Object | Blob

Test:

public byteLength(raw: String): Number source

import {byteLength} from 'web-cell/source/utility/resource.js'

Params:

NameTypeAttributeDescription
raw String

Return:

Number

Length in Half-width characters

public classNameOf(object: *): string source

import {classNameOf} from 'web-cell/source/utility/object.js'

Params:

NameTypeAttributeDescription
object *

Return:

string

public clearPath(raw: String): String source

import {clearPath} from 'web-cell/source/utility/resource.js'

Params:

NameTypeAttributeDescription
raw String

Return:

String

Test:

public component(meta: Object): function(elements: DecoratorDescriptor[]): Object source

import {component} from 'web-cell/source/component/decorator.js'

Register a component

Params:

NameTypeAttributeDescription
meta Object
meta.template String | Node
  • optional

HTML template source or sub DOM tree

meta.style String | Element
  • optional

CSS source or <style />

meta.data Object
  • optional

Initial data

meta.tagName String
  • optional

Name of an HTML original tag to extend

Return:

function(elements: DecoratorDescriptor[]): Object

Component class decorator

Test:

public decodeBase64(raw: String): String source

import {decodeBase64} from 'web-cell/source/utility/resource.js'

Params:

NameTypeAttributeDescription
raw String

Base64 encoded data

Return:

String

Binary data

public decodeMarkup(source: String): String source

import {decodeMarkup} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
source String

Return:

String

Markup entries are tranformed back to Special characters or Escape Markup tags

public decoratorOf(target: Function | Object, key: String, value: Function | Object | *, descriptor: Object): DecoratorDescriptor source

import {decoratorOf} from 'web-cell/source/utility/object.js'

Params:

NameTypeAttributeDescription
target Function | Object

Class or its prototype

key String

Member name

value Function | Object | *

{ set, get } for Field accessors

descriptor Object
  • optional

Use for Object.defineProperty()

Test:

public delay(second: number): Promise source

import {delay} from 'web-cell/source/utility/event.js'

Params:

NameTypeAttributeDescription
second number
  • optional
  • default: 0

Return:

Promise

Wait seconds in Macro tasks

public delegate(selector: String, handler: EventHandler): Function source

import {delegate} from 'web-cell/source/utility/event.js'

DOM event delegate

Params:

NameTypeAttributeDescription
selector String
handler EventHandler

Return:

Function

Handler wrapper

Test:

public documentTypeOf(node: Node): String source

import {documentTypeOf} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
node Node

Test:

public encodeBase64(raw: String): String source

import {encodeBase64} from 'web-cell/source/utility/resource.js'

Params:

NameTypeAttributeDescription
raw String

Binary data

Return:

String

Base64 encoded data

public encodeMarkup(source: String): String source

import {encodeMarkup} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
source String

Markup source code

Return:

String

Special characters are tranformed to Markup entries

public extend(target: Object, source: ...Object): Object source

import {extend} from 'web-cell/source/utility/object.js'

Merge own properties of two or more objects together into the first object by their descriptor

Params:

NameTypeAttributeDescription
target Object

An object that will receive the new properties if source are passed in

source ...Object

Additional objects containing properties to merge in (Value of null or undefined will be skipped)

Return:

Object

The target parameter

Test:

See:

public fetch(URI: String | URL, request: Object): Promise<XMLHttpRequest> source

import {fetch} from 'web-cell/source/utility/HTTP.js'

Enhanced fetch() with Progress handlers based on XMLHttpRequest()

Params:

NameTypeAttributeDescription
URI String | URL
request Object
  • optional
  • default: { }
request.method String
  • optional
  • default: 'GET'
request.body String | Object
  • optional
request.headers Object
  • optional
request.upload Object
  • optional
  • default: { }

Event handlers of XMLHttpRequestUpload()

request.extra ...Object
  • optional

Writable properties of XHR object

Return:

Promise<XMLHttpRequest>

Resolved on load event or Rejected on error event

public async fileTypeOf(URI: String): Object source

import {fileTypeOf} from 'web-cell/source/utility/resource.js'

Params:

NameTypeAttributeDescription
URI String

HTTP(S) URL, Data URI or Object URL

Return:

Object

Return Properties:

NameTypeAttributeDescription
schema String

URI schema (http, https, data or blob)

type String

File type (same as the Extension name of a file)

Test:

public getPropertyDescriptor(object: *, key: string): Object source

import {getPropertyDescriptor} from 'web-cell/source/utility/object.js'

Params:

NameTypeAttributeDescription
object *
key string

Property name

Test:

public indexOf(node: Node, inNodes: Boolean): Number source

import {indexOf} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
node Node
inNodes Boolean
  • optional

Seek in all kinds of Node

Return:

Number

The index of node in its siblings

Test:

public insertTo(parent: ParentNode, child: Node | String, position: Number | Node, inNodes: Boolean) source

import {insertTo} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
parent ParentNode
child Node | String

https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/append#Parameters

position Number | Node
  • optional
inNodes Boolean
  • optional

Seek in all kinds of Node

Test:

public insertableIndexOf(list: Node[], index: Number): Number source

import {insertableIndexOf} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
list Node[]
index Number
  • optional

Return:

Number

public isXDomain(URI: string | URL): boolean source

import {isXDomain} from 'web-cell/source/utility/HTTP.js'

Params:

NameTypeAttributeDescription
URI string | URL

Full URL of a resource

Return:

boolean

Whether it's cross domain to current page

public likeArray(object: *): Boolean source

import {likeArray} from 'web-cell/source/utility/object.js'

Params:

NameTypeAttributeDescription
object *

Return:

Boolean

Test:

public async loadDOM(tree: Node, base: String): Node source

import {loadDOM} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
tree Node
base String
  • optional

Base path after location.pathname

Return:

Node

The tree

Test:

public loadModule(URI: String | URL, ESM: Boolean): Promise<Event> source

import {loadModule} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
URI String | URL
ESM Boolean
  • nullable: true

Return:

Promise<Event>

public makeNode(fragment: String | Node[]): DocumentFragment source

import {makeNode} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
fragment String | Node[]

Return:

DocumentFragment (nullable: true)

public mapData(meta: DecoratorDescriptor) source

Decorator for attributeChangedCallback() method

Params:

NameTypeAttributeDescription
meta DecoratorDescriptor

Test:

public mapProperty(meta: DecoratorDescriptor) source

import {mapProperty} from 'web-cell/source/component/decorator.js'

Decorator for observedAttributes getter

Params:

NameTypeAttributeDescription
meta DecoratorDescriptor

Test:

public * mapTree(node: Object, fork_key: String) source

import {mapTree} from 'web-cell/source/utility/object.js'

Traverse Object-tree

Params:

NameTypeAttributeDescription
node Object

Object tree

fork_key String

Key of children list

Test:

public mediaReady(context: Element | Document): Promise source

import {mediaReady} from 'web-cell/source/utility/event.js'

Params:

NameTypeAttributeDescription
context Element | Document
  • optional

Return:

Promise

Resolved when all media elements in context are loaded

public multipleMap(list: Iterable, filter: function(item: *, index: number, list: Iterable): *): Array source

import {multipleMap} from 'web-cell/source/utility/object.js'

Equivalent to the integration of Array's map() & filter() methods

Params:

NameTypeAttributeDescription
list Iterable
filter function(item: *, index: number, list: Iterable): *

Return item itself to reserve, undefined or null to ignore, or Array to merge in.

Return:

Array

Test:

See:

public on(type: String, selector: String): Function source

Params:

NameTypeAttributeDescription
type String
selector String

Return:

Function

Decorator for Event handler

public parse(raw: String): Object source

Params:

NameTypeAttributeDescription
raw String

JSON source code

Return:

Object

Test:

public parseHash(keyChar: String, valueChar: String, raw: String, mapper: function(key: String, value: String): Array): Object source

import {parseHash} from 'web-cell/source/utility/resource.js'

Params:

NameTypeAttributeDescription
keyChar String
valueChar String
raw String
mapper function(key: String, value: String): Array
  • optional

Return:

Object

Test:

public parseHeader(raw: String): Object source

import {parseHeader} from 'web-cell/source/utility/HTTP.js'

Params:

NameTypeAttributeDescription
raw String

Return:

Object

Test:

public readAs(file: File, type: String, encoding: String): String | ArrayBuffer source

Params:

NameTypeAttributeDescription
file File
type String
  • optional
  • default: 'DataURL'

https://developer.mozilla.org/en-US/docs/Web/API/FileReader#Methods

encoding String
  • optional
  • default: 'UTF-8'

https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsText#Parameters

Return:

String | ArrayBuffer

public async request(URI: string, method: string, body: String | Object | Node, headers: Object, option: Object): Object source

import {request} from 'web-cell/source/utility/HTTP.js'

HTTP request

Params:

NameTypeAttributeDescription
URI string

HTTP URL

method string
  • optional
  • default: 'GET'
body String | Object | Node
  • optional

Data to send

headers Object
  • optional
option Object
  • optional

Parameters of fetch about XMLHttpRequest()

Throw:

URIError

status < 400

Test:

public serialize(form: Element): String | FormData | Object source

import {serialize} from 'web-cell/source/utility/HTTP.js'

Params:

NameTypeAttributeDescription
form Element

<form /> or <fieldset />

Return:

String | FormData | Object

Test:

public stringify(data: Object): String source

import {stringify} from 'web-cell/source/utility/resource.js'

Params:

NameTypeAttributeDescription
data Object

Return:

String

JSON source code

Test:

public toDataURI(raw: String, type: String): String source

import {toDataURI} from 'web-cell/source/utility/resource.js'

Params:

NameTypeAttributeDescription
raw String

Binary data

type String
  • optional
  • default: ''

MIME type

Return:

String

public toIterable(arrayLike: Object): Iterable source

import {toIterable} from 'web-cell/source/utility/object.js'

Params:

NameTypeAttributeDescription
arrayLike Object

Return:

Iterable

arrayLike

public trigger(element: Element, event: String | Event, detail: *, bubbles: Boolean, cancelable: Boolean, composed: Boolean): Boolean source

import {trigger} from 'web-cell/source/utility/event.js'

Params:

NameTypeAttributeDescription
element Element
event String | Event
detail *
  • nullable: true

Additional data

bubbles Boolean
  • nullable: true
cancelable Boolean
  • nullable: true
composed Boolean
  • nullable: true

Whether the event will cross from the shadow DOM into the standard DOM after reaching the shadow root

Return:

Boolean

Event be canceled or not

public unique(list: Array, condition: String | Symbol | UniqueComparer): Array source

import {unique} from 'web-cell/source/utility/object.js'

Params:

NameTypeAttributeDescription
list Array

Original array

condition String | Symbol | UniqueComparer
  • optional

Return:

Array

Deduplicated new array

Test:

public watchAttributes(element: Element, names: string[], callback: AttributeWatcher): MutationObserver source

import {watchAttributes} from 'web-cell/source/utility/DOM.js'

Params:

NameTypeAttributeDescription
element Element
names string[]
callback AttributeWatcher

Return:

MutationObserver

Test: