1.0.0 • Published 9 years ago

std-js v1.0.0

Weekly downloads
2
License
GPL-3.0
Repository
github
Last release
9 years ago

std-js


Build Status Join the chat at https://gitter.im/shgysk8zer0/std-js

A JavaScript library for making front-end development sane!

The purpose of this library is not so much to provide alternatives to jQuery, etc, but rather to provide polyfills and wrappers to native JavaScript, enabling use of modern JavaScript with less headache over browser support and implementation.
It was, in part, influenced by the syntax of jQuery, but its purpose is different in that this places little emphasis on style and animation. Rather, its emphasis is on asynchronous event handling though Mutation Observers and Promises.

Example

$('a').filter(function(link) {
	return link.origin === location.origin;
}).click(function(event) {
	event.preventDefault();
	fetch(this.href).then(function(resp) {
		if (resp.ok) {
			history.pushState({}, document.title, link.href);
			if (resp.headers.get('Content-Type').startsWith('application/json')) {
				return resp.json();
			} else {
				throw 'Unsupported Content-Type in response.';
			}
		} else {
			throw 'Request failed';
		}
	}).then(...);
});