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

lsn

v0.0.9

Published

Add and remove listener events on elements in the document.

Downloads

16

Readme

lsn

(c)Bumblehead, 2013 MIT-license

Overview:

Add and remove listener events on elements in the document.

  • lsn( elem, event, fn );
  • lsn.rm( elem, event, fn );

Caveats:

Research reveals problems with all listener-wrapper scripts available on the internet. None of them are perfect. The script demonstrated on msdn here is the best one I've seen. The 'terms and conditions' around msdn's sample code, however, are prohibitive and the author has not released a public version of the samples.

David Mark owns the best host method checking techniques. This is his: /^(?:function|object|unknown)$/.test(typeof object[methodname]). I wanted to avoid using it but there's no other reliable technique for finding if attachEvent is available on document.documentElement. typeof document.documentElement.attachEvent returns object or function in different JScript environments.

One might consider using DOM0 'onclick'-style event listeners exclusively but not when seeing that it is dramtically slow compared to addEventListener. Who wants slow response times for click events? not me.

Due to the above considerations, this script only provides a primitive wrapper around addEventListener and attachEvent. You may want a more comprehensive solution. 'onclick'-style event listeners are not supported. If addEventListener or attachEvent are not supported by the host environment this script will not handle the event for you -prepare your application to degrade nicely.

Additionally:

  1. no support for 'capturing phase' in IE (capturing an event: when an event is bubbling up, elements queued to 'capture' the event will not fire once the event has been captured.)
  2. order of handler execution is inconsistent. most browsers will FIFO (first in first out), but mshtml will LIFO.
  3. error handling for events passed to certain objects is not anticipated. It may be OK to send these methods a window object or it may not be -no error handling for this.
  4. the this is not normailized in any way.
  5. no attempt is made to solve your memory leak issues.

Because this script does not handle edge cases, it is small. It also memoizes the supported listener method which often makes it faster.


Install:

lsn may be downloaded directly or installed through npm.

  • npm
$ npm install lsn
  • Direct Download
$ git clone https://github.com/iambumblehead/lsn.git

Test:

Tests are not automated and are performed by loading a document in the browser and using the browser console.

  • load test/index.html in your browser and run tests from the console.

License:

scrounge

(The MIT License)

Copyright (c) 2013 Bumblehead [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.