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

jquery.bsonbuilder

v1.0.0

Published

jQuery BSON builder

Readme

BSON builder

This library helps to integrate a BSON builder using jQuery.

You can see this plugin in action: online demo.

Get started

You can download plugin files from the source repository: js/ sub-directory.

This plugin is also available as a NPM package: npm install jquery.bsonbuilder

Setup

$("selector").bsonBuilder(options)

Following options are available to setup BSON builder.

onLoad (function): Callback function which is given the container element and BSON document when BSON builder is loaded (e.g. {element: ..., bson: {}}).

supportsWildcard (boolean): Supports wildcard as BSON value.

containerDecorator (function): Decorator function, is called each time an .editor element is appended to either a document or array view. The given .editor allows user to update document properties or array items, and it's created with an input.child-name (optional, if editing document, to type the property name), a select.child-type (to choose the type of BSON value to be added) and a button (to validate the creation of new BSON value). These prepared child elements must not be .removed (use .detach instead if needed). The decorator function must return the decorated .editor element.

childDecorator (function): Decorator function, is called each time a .bson value element is added. The given .bson contains 3 button elements: .move-up (possibly disabled if already first), .move-down (possibly disabled if already last) or .remove. These prepared child elements must not be .removed (use .detach instead if needed). The decorator function must return the decorated .bson element.

showPropertyValueEditor (function): Configuration function which returns a callback function to be called with an .editor element (see containerDecorator option) and the type (string) of BSON value to edited. The returned function must itself return a form element to be used to edit the value; e.g. function(editor, typ){ return $('<input type="text" class="bson-value" />') } . The configuration function showPropertyValueEditor is called with the default callback (showPropertyValueEditor: function(defCall){ return defCall }).

hidePropertyValueEditor (function): Callback function called with an .editor element, to hide when necessary the value editor added by function returned by showPropertyValueEditor; e.g. function(editor){ $(".bson-value", editor).css({'display':"none"}) } .

Following types are those supported by editors of BSON values: document, array, boolean, datetime, double, float, integer, long, objectid, string.

Event

Each time the managed BSON is updated, a bson.change event is fired with following properties.

action: Either add, remove, move-up or move-down.

bson: The BSON root document, of following form.

{
  doc1:{
    _type:"document",
    val:{
      bool2:{
        _type:"boolean",
        val:false
      },
      double2:{
        _type:"double",
        val:1
      }
    }
  },
  arr1:{
    _type:"array",
    val:[
      {
        _type:"datetime",
        val:null
      },
      {
        _type:"integer",
        val:123
      },
      { _type:"wildcard" }
    ]
  },
   bool1:{
    _type:"boolean",
     val:true
  },
  date1:{
    _type:"datetime",
    val:(new Date(1420156800000))
  },
  double1:{
    _type:"double",
    val:1.23
  },
  float1:{
    _type:"float",
    val:2.34
  },
  long1:{
    _type:"long",
    val:12345
  },
  oid1:{
    _type:"objectid",
    val:4321
  },
  str1:{
    _type:"string",
    val:"a_value"
  }
}

change: Data updated in the BSON: {'bson': changedPart, 'parent': changeParent, 'element': changeElement}. The bson sub-property is of form {_type:..., val:...} (see the formats of BSON values in previous example of root document).