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

libj

v1.3.1

Published

## Adds following to __window__ variable: - __log__: which is a shortcut for console.log - __$__ and __jQuery__: the jquery's famous $ and jQuery variable - __unerscore(_)__: underscore - __stackTrace function() -> Error__: returns an error object contain

Downloads

25

Readme

libj

Adds following to window variable:

  • log: which is a shortcut for console.log
  • $ and jQuery: the jquery's famous $ and jQuery variable
  • unerscore(_): underscore
  • stackTrace function() -> Error: returns an error object containing current stack trace
  • logStackTrace function() -> void: prints current stack trace in console

Adds the following methods to any jQuery variable:

  • hasAttr function (name) -> Boolean: checks if a jquery object has the given attribute.

    $('.test').hasAttr('id')

  • equals function(jQueryObject) -> Boolean: checks if a jquery object equals the given jquery object.

    $('.test').equals($('.test'))

  • outerHTML function() -> String: returns the jquery object's outer html.

    $('.test').outerHTML()

Adds the following methods to javascript Number:

  • padZero function(size) -> String: inserts 0s before a number until the length is equal to size parameter

    var x = 123; x.padZero(5) prints: 00123

  • format function(separator = ',') -> String: thousand separator for mostly currencies

    var x = 123000; x.format('/') prints: 123/000

Adds the following methods to javascript String:

  • format function(templateString, ...args): just like c# String.format function

    String.format('Hi, {0}', 'Akbar') prints: Hi, Akbar

  • endsWith function(suffix): just like c# String.endsWith function

Adds the following to FormData:

  • print function() -> String: prints FormData object
  • put function(object) -> FormData: puts all properties of object recursively into FormData

jQuery classes polyfill for IE

will be automatically injected on import

IE10 viewport hack for Surface/desktop Windows 8 bug

will be automatically injected on import

fix for safari bug on readonly input

will be automatically injected on import

Opacity:

  • import 'libj/dist/opacity.css' to add opacity-{0, 25, 50, 75, 100} css classes
  • getOpacityCss(opactiy) -> String: returns css style for the given opacity parameter. opacity must be a fload number between 0 and 1

Media Query:

  • queryMedia function(query, callOnChange, callback) -> void:

    • @param {string} query: e.g: '(max-width: 769px)'
    • @param {boolean} callOnChange: whether or not to invoke callback parameter on window resize
    • @event callback : function (isMatch: boolean) -> void
  • queryMediaSync function(query = '(max-width: 769px)') -> Boolean: checks css query and returns the result immediateley

Id Generator:

  • guid function() -> String: returns a c# Guid.NewGuid().ToString("N") like string

    guid() returns: 976edaa0d2464573a6ea01aabaa98899

  • newId function() -> String: returns guid() plus a prefix to make it suitable for html id attributes

    newId() returns: e_976edaa0d2464573a6ea01a4bca98899

Browser support:

  • browserSupport class():
    • methods:
      • fileInput(): returns true if browser supports file input
      • fileApi(): returns true if browser supports FileReader
      • dragDropApi(): returns true if browser supports drag & drop

Type system:

  • isVoid function(value) -> Boolean: checks if the value is either null or undefined

    isVoid(null) returns: true

  • isJquery function(value) -> Boolean: checks if the value is an instance of jQuery

    isJquery($('.test')) returns: true

  • toJquery function(value) -> jQuery: if the value is not a jQuery instance, assumes that value is a jquery selector and returns the jquery instance of that selector

    toJquery($('.test')) returns: $('.test') variable toJquery('.test') returns: $('.test') variable

Utility:

  • callSafe function(func) -> return value of func: calls the given function if it is available
  • kebab_case_to_camelCase function(kebabCase) -> String: converts kebab-case string into camelCase equivalent

    kebab_case_to_camelCase('libj-underscore') returns: libjUnderscore

  • containsArabic function(value) -> Boolean: checks if a string contains persian or arabic characters
  • isKeyAlphaNumeric function(keyCode) -> Boolean: checks if the given keyCode of a jquery's keyup or keydown events is either digit or letter
  • isKeyTextInput function(keyCode) -> Boolean: checks if the given keyCode of a jquery's keyup or keydown events is either digit or letter and is NOT backspace: 8 nor delete: 46
  • render function(template: String, data: Object) -> String: renders a template using the data as its model with underscorejs template engine
  • toEnglishNumbers function(string) -> String: changes arabic or persian digits in a string to english digits
  • flatten and unflatten from https://www.npmjs.com/package/flat
  • isBuffer from https://github.com/feross/is-buffer

Synchronization:

  • spinLock class(locked: func, unlocked: func):
    • methods:
      • lock() -> void: locks the object
      • unlock() -> void: unlocks the object
      • isLocked() -> Boolean: tells if the object is locked
      • waitForLock(callback: func): invokes the callback asynchronously when the object is unlocked

Mime types:

  • MediaTypes class():
    • methods:
      • acceptToFileTypes(accept): convert Html5 accept string to array of separate accepts
        • @param {String} accept example: image/*, audio/*, video/*, ....
      • getExtension(type): returns file extension of the given mime type.
      • getMediaType(extensionOrPath): returns mime type of given file extension or url
      • getIconPath(fileIconPath, extension, size = 48, type = 'png'): returns icon url of the given file extension
        • @param {String} fileIconPath: folder in wwwroot on server e.g: /file-icon-set
        • @param {Number} size: 16, 24, 48, 64, 128
        • @param {String} type: png | gif
      • getUrlThumb(url, done, iconSize = 48, iconType = 'png'): returns icon for a given url (of a file)
        • @returns an object of type:
          • path {String}: url of the icon
          • isIcon {Boolean}: whether it is icon or not
          • height {Number | Null}: iconSize parameter if isIcon is true
      • getFileThumb(file, done, iconSize = 48, iconType = 'png'): returns icon for a given file (File)
        • @returns an object of type:
          • path {String}: data uri of icon
          • isIcon {Boolean}: whether it is icon or not
          • height {Number | Undefined}: iconSize parameter if isIcon is true

Local Database:

  • Database class():
    • methods:
      • set(key, value): sets the value of key
      • get(key, seed): gets the value of key and seeds that key for the first usage
      • remove(key): removes key
      • clear(): clears database
      • all(): returns all as array of:
        • key
        • value

Ajax:

  • registerXsrfHeaderInAjaxPost function() -> void: registers current xsrf.headerName() and xsrf.value() in ajax-post
  • createUrl function(url) -> String: gets localized url
  • createAjaxOptions function(method, url, data, success, error, completed) -> jQuery ajax options
  • send function(method, url, data, success, error, completed) -> void
  • sendGet function(url, data, success, error, completed) -> void
  • sendPost function(url, data, success, error, completed) -> void

XSRF:

  • xsrfConfig class():
    • methods:
      • headerName(xsrfHeaderName): gets or sets XSRF header name
      • value(containerSelector, tagName): gets or sets XSRF value
      • tag(): gets hidden input of xsrf tag provided by asp.net core

Culture:

  • cultureConfig class():
    • methods;
      • cultures(cultures): gets or sets allowed cultures
      • cultureObjects(): gets culture objects as array of:
        • id: culture
        • text: name of culture
        • url: current url with this culture
      • defaultCulture(culture): gets or sets default (fallback) culture, used for routing and operational stuff
      • defaultUICulture(culture): gets or sets default UI culture, used for localization mostly
      • culture(culture): gets or sets current culture
      • getCultureName(culture): gets name of the give culture
      • dir(culture): gets direction (rtl, ltr) of the give culture. if the culture passed is null or undefined gets direction of current culture
      • calendar(): gets calendar of the current culture
  • _.activeCultures Array of String

Google:

  • googleConfig class():
    • methods:
      • googletMapApiKey(apiKey): gets or sets current google map api key

Url:

  • currentUrl: a method returning info about current url
    • culture: culture
    • url: path part of url
    • query: query string

Server Data:

  • serverItems():
    • properties:
      • serverItems: An object of server and tags
      • serverResults: An array of server Results
        • name
        • title
        • message
        • color
        • duration
        • returnValue

Imaging:

  • thumberOptions(options): gets or sets thumber options
    • @param options:
      • extensions: 'png, jpg, jpeg, bmp'
      • widthParameterName: 'w'
      • heightParameterName: 'h'
      • qualityParameterName: 'q'
  • getImageUrl(path, quality = 100, width = null, height = null): gets url of the compressed image

Scrollbar:

  • import 'libj/dist/scrollbar.css' to have nice little scrollbar on the window instead of the default one
  • infiniteScroller(scrollTarget, callback, locked, unlocked):
    • @param scrollTarget: jQuery object for target container. pass undefined to watch window scroll
    • @param callback: function (page, done: function(boolean)) -> void
    • @param locked: function () -> void
    • @param unlocked: function () -> void
  • windowScroll object:
    • methods:
      • remove() -> void: removes window scrollbar
      • restore() -> void: restores window scrollbar