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 🙏

© 2026 – Pkg Stats / Ryan Hefner

client-lib

v0.0.12

Published

Client side shared library

Readme

client-lib

Shared Client side components.

Templates

To use a template included in this library, Coffeescript {templateName} = require 'client-lib/dist/templates.js' Javascript templateName = require('client-lib/dist/templates.js).templateName

Available Templates

  • editorAssetsThumbnails

    Provides a list of thumbnail images as long as you provide an AssetCollection.toJSON() object as the template context's images value:

      @$el.html(@template(images: @collection.toJSON()))
  • locationsFileDialog

    Provides a modal template for uploading and selecting images. Takes no arguments.

      @$el.html(@template())
    	
  • uploader

    Provides a Drag and Drop targetable interactive upload markup template (you have to provide the functionality yourself). Takes no arguments.

      @$el.html(@template())
    	
  • uploadItem

    Provides table rows for individual file uploads. Intended for use with the uploader template. Takes a contextualized FileUpload model as the context. Usually appended to an existing tbody element. Example usage:

      context =
        id: @model.cid
        filename: @model.get('name')
        size: @model.get('size')
        hasError: false
        valid: true
        autoUpload: true
        progress: @model.get('progress') * 100
        startMsg: "Upload File"
        cancelMsg: "Cancel Upload"
      ## unobserves any current event handlers
      @undelegateEvents()
      ## gets the current item
      $item = @getItemElement()
      ## replaces the current item or appends to 
      ## the element.
      if $item.length > 0
        $item.replaceWith(uploadItem(context))
      else
        @$el.append(uploadItem(context))
      ## re-observes event handlers on the new item.
      @delegateEvents(@events)

Available Handlebars helper functions

  • thumbnail

    Produces a thumbnail image from an AssetModel

  • url

    Produces a downloadable asset url from a passed identifier

  • dateformat

    Formats dates in mm/dd/yyyy format.

  • datetimeformat

    Formats dates in ddd mmm dd yyyy h:MM tt format

  • filesizeformat

    Produces human readable kb or mb filesizes from b sized file sizes.

  • filetype

    Produces an appropriate filetype icon from a filename or mime-type

  • getIcon

    Produces the appropriate icon for an atm network

  • replaceSpace

    replaces whitespace with "-" and ! with ""

  • getLocationType

    Distinguishes atms from branches given an atm network

  • roundNumber

    Converts a js number to two fixed decimal places

  • isUnread

    converts the passed read state to the appropriate "" or "unread" string for rendering.

  • userAvatar

    provides a downloadable avatar uri given a user identifier

Available Utilities

To use any of the utilities provided:

Coffeescript

{utilityName} = require 'client-lib/dist/utilityName.js'

Javascript

utilityName = require('client-lib/dist/utilityName.js').utilityName
  • ContentTypeHelpers

    Converts filenames to file types and file types to icons. Exposes contentTypeToIcon and extensionToContentType methods.

Availible Views

To use any of the views provided:

Coffeescript

{viewName} = require 'client-lib/viewName.js'

Javascript

viewName = require('client-lib/viewName.js').viewName
  • AssetGrid

    Base class for collection-based grid views.

  • AssetCollectionAssetGrid

    Extends AssetGrid Provides an AssetCollection by default. Uses the editorAssetsThumbnails template to render assets in a grid. Fires an assetCollectionAssetGrid:imageSelected event when an image in the grid is clicked, providing the asset's id as an argument to listening event handlers.

  • LocationsDialogAssetGrid

    Extends AssetCollectionAssetGrid Provides ContentType filtering to limit displayed assets to images only.

  • LocationsFileDialogView

    Provides an interactive Bootstrap Modal dialog that can upload and select files. Fires a locationsFileDialogView:imageSelected event when an image is selected, providing the asset's id to listening event handlers.

  • Uploader

    Provides a Drag and Drop and Button enabled interactive upload interface. Displays upload item progress and auto-removes upload items from the view when the upload is complete.

  • UploadItem

    Displays information about it's upload item, including progress and provides ux for canceling in-process file uploads.

  • notify

    Provides a styled notification component. Implemented as a simple function that takes a single string argument to display.

Available Models

To use any of the models provided:

Coffeescript

{modelName} = require 'client-lib/dist/modelName.js'

Javascript

modelName = require('client-lib/dist/modelName.js').modelName
  • asset/model/AssetCollection

    Provides asset management. Default uri is '/_/api/asset/' Default model type is AssetModel Both defaults are overrideable at instantiation or via AssetCollection.extend.

  • asset/model/AssetModel

    Provides a model for managing assets. Attributes include filename, description, contentType, uploadedOn, uploadeBy, and labels. Exposes isPdf, isSelected, isText, isTrash, notifyLabelChange, and trash methods.

  • FileUploads

    A collection for managing file uploads. Default uri is '/_/api/asset' Default model type is FileUpload Both defaults are overrideable at instantiation or via FileUploads.extend.

  • FileUpload

    Provides ajax file uploads. attributes include name type, size, maxFileSize, pending, progress, complete, and file. Implements an overridden sync method that converts a provided browser File object into a consumable multipart-form-data encoded representation to provide ajax-transferrable file uploads. Fires a fileupload:uploadStart event when an upload has begun transferring to the server, passing itself to listening event handlers. Fires a fileuplaod:complete event when the upload has completed. Fires an error event with the model, transport and sync options provided as arguments when an upload fails. Exposes methods to cancel the file upload while it is in progress.