npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

go-native

v1.0.0

Published

A Javascript polyfills' collection which let you use native javascript.

Downloads

1,598

Readme

Go-native

version
Javascript polyfills which let you use native javascript. Rewrite with ES2015 module.
CSS3 selectors, CSS3 media queries, ES5 extensions and a bunch of DOM utilities.
Tested on IE 8+, Firefox 17+, Chrome 15+, Safari 4+, Opera 10+.

Install

bower install go-native --save

Contents

####go-native.ie8

  • NWMatcher (for selectivizr)
  • selectivizr
  • respond.js
  • ES5 Array (every, filter, forEach, indexOf, lastIndexOf, map, reduce, reduceRight, some), Date (now, parse, toISOString, toJSON), Function (bind), Object (create, defineProperties, defineProperty, freeze, getOwnPropertyDescriptor, getOwnPropertyNames, getPrototypeOf, isExtensible, isFrozen, isSealed, keys, preventExtensions, seal) and String (trim) extensions
  • Event-related methods:
    • preventDefault
    • stopPropagation
  • EventTarget methods:
    • addEventListener
    • removeEventListener
  • Element-related properties:
    • el.childElementCount
    • el.firstElementChild
    • el.lastElementChild
    • el.nextElementSibling
    • el.previousElementSibling
  • Node-related properties:
    • node.textContent
  • Window-related properties/methods:
    • window.getComputedStyle
    • window.innerWidth
    • window.innerHeight
    • window.pageXOffset / window.scrollY
    • window.pageYOffset / window.scrollX

####go-native

  • ES5 methods:
    • Number.isNaN
    • String.prototype.repeat
  • Element-related properties:
    • el.classList
  • Node-related properties:
    • ChildNode.remove
  • Length
  • requestAnimationFrame
  • optimizedResize
  • extend
  • isNodeList
  • DOM related utilities
    • DOM.ready
    • isInViewport
    • indexOf
    • getOuterWidth
    • getOuterHeight
    • getOffsetLeft
    • getOffsetTop
    • getSupportedProp
    • getClosest
    • getParents
    • getParentsUntil
    • getSiblings
    • createElement
    • append
    • prepend
    • wrap
    • wrapAll
    • unwrap

Usage

import go-native in your script (make sure link to src folder, not dist folder)

import * as gn from "../../src/go-native";

Or add go-native.js and go-native.ie8.js to your page.

<!--[if (lt IE 9)]>
  <script src="path/to/go-native.ie8.js"></script>
<![endif]-->
<script src="path/to/go-native.js"></script>

Methods

DOM.ready
gn.ready(function () {
  // do something
  // on DOM ready
});
isInViewport
var el = document.querySelector('.element');
if (gn.isInViewport(el)) {
  // when element is in viewport
  // do something
}
indexOf
var index,
    list = document.querySelectorAll('.list > li'),
    current = document.querySelector('.current');

index = gn.indexOf(list, current);
getOuterWidth
// content + padding + border + margin
var box = document.querySelector('.box'),
    boxWidth = gn.getOuterWidth(box);
getOuterHeight
// content + padding + border + margin
var box = document.querySelector('.box'),
    boxHeight = gn.getOuterHeight(box);
getWidth
// content width
var box = document.querySelector('.box'),
    boxWidth = gn.getWidth(box);
getHeight
// content height
var box = document.querySelector('.box'),
    boxHeight = gn.getHeight(box);
getOffsetLeft
var box = document.querySelector('.box'),
    boxLeft = gn.getOffsetLeft(box);
getOffsetTop
var box = document.querySelector('.box'),
    boxTop = gn.getOffsetTop(box);
getSupportedProp
var transitionDuration = gn.getSupportedProp(['transitionDuration', 'WebkitTransitionDuration', 'MozTransitionDuration', 'OTransitionDuration']);
console.log(transitionDuration);
getClosest
var element = document.querySelector('.element'),
    red = gn.getClosest(element, '.red');
getParents
var element = document.querySelector('.element'),
    red = gn.getParents(element, '.red');
getParentsUntil
getSiblings
var element = document.querySelector('.element'),
    siblings = gn.getSiblings(element);
createElement
var el = gn.createElement({
  tagName: 'div',
  id: 'foo',
  className: 'foo',
  children: [{
   tagName: 'div',
   html: '<b>Hello, creatElement</b>',
   attributes: {
     'am-button': 'primary'
   }
  }]
});
append
var container = document.querySelector('.container');
gn.append(container, '<li>Peach</li>');
gn.append(container, el);
prepend
var container = document.querySelector('.container');
gn.prepend(container, '<li>Pear</li>');
gn.prepend(container, el);
wrap
var p = doc.querySelectorAll('p'),
    div = doc.createElement('div');
gn.wrap(p, div);
wrapAll
var p = doc.querySelectorAll('p'),
    div = doc.createElement('div');
gn.wrapAll(p, div);
unwrap
var container = doc.querySelectorAll('.container');
gn.unwrap(container);

Credit:

NWMatcher from dperini.
selectivizr from keithclark.
respond from scottjehl.
Length from heygrady.
requestAnimationFrame from darius.
indexOf from HubSpot/youmightnotneedjquery.

ES5 Array, Function, Date, Object and String extensions from 280north/narwhal.

preventDefault, stopPropagation, addEventListener, removeEventListener, node.textContent and optimizedResize from the Mozilla Developer Network.

el.classList, el.childElementCount, el.firstElementChild, el.lastElementChild, el.nextElementSibling, el.previousElementSibling, ChildNode.remove, window.getComputedStyle, window.innerWidth, window.innerHeight, window.pageXOffset, window.pageYOffset, Array.isArray, Number.isNaN and String.prototype.repeat from Alhadis.

DOM.ready, isInViewport, getClosest, getParents, getParentsUntil and getSiblings from Chris Ferdinandi.

License

This project is available under the MIT license.