Skip to content

sweaxizone/w3cextension.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

com.sweaxizone.w3c.extension

Various global utilities that are not included in the ECMAScript and WHATWG/W3C APIs. Not focusing on web DOM APIs for now, as I plan to use this for other purposes.

Getting started

Clutter the global object by using the following import statement:

import "com.sweaxizone.w3c.extension";

Short-augmented events

The following class defines play and stop events.

// media player
class MediaPlayer extends SAEventTarget {
    // declare events
    declare [EventRecord]: {
        play: MediaPlayerEvent,
        stop: MediaPlayerEvent,
    };
}

Extending MediaPlayer with more events:

// media player
class MoreSpecializedPlayer extends MediaPlayer {
    // declare events
    declare [EventRecord]: MediaPlayer[typeof EventRecord] & {
        // more events...
    };
}

Note that event types must implement the Event interface.

Other additions

  • assert
  • AssertionError
  • trace(...) (equivalent to console.log())
  • etrace(...) (equivalent to console.error())
  • Math.clamp(value, from, to)
  • BigInt.min(...)
  • BigInt.max(...)
  • SAByteArray (like Adobe Flash's ByteArray)
  • isXMLName(argument) (like E4X's isXMLName())
  • Namespace (like E4X's Namespace)
  • QName (like E4X's QName)
  • Iterator.prototype.length()
  • Chars
  • String.prototype.chars()

License

Apache 2.0

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published