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

ldsorg

v2.5.4

Published

A JavaScript library for accessing LDS.org with Node.js or a browser

Downloads

45

Readme

ldsorg.js

This is a thin layer over the LDS.org api. All of the data is exactly the same with one exception: pictures are included in calls to individuals and households.

Questions? Comments? Leave an issue or join the discussion on Google Groups

Installation

Note that hogwarts.js is for testing and thus optional. If you use hogwarts.js you must also include chance.js.

node.js

npm install ldsorg

browser

via bower

bower install ldsorg
script(src="bower_components/forEachAsync/forEachAsync.js")
script(src="bower_components/forAllAsync/forAllAsync.js")
script(src="bower_components/join/join.js")
script(src="bower_components/lateral/lateral.js")
script(src="bower_components/ldsorgjs/ward.js")
script(src="bower_components/ldsorgjs/stake.js")
script(src="bower_components/ldsorgjs/browser.js")
script(src="bower_components/ldsorgjs/ldsorg.js")
script(src="bower_components/ldsorgjs/cache-browser.js")
script(src="bower_components/chance/chance.js")
script(src="bower_components/ldsorgjs/hogwarts.js")
<script src="bower_components/forAllAsync/forAllAsync.js"></script>
<script src="bower_components/forEachAsync/forEachAsync.js"></script>
<script src="bower_components/join/join.js"></script>
<script src="bower_components/lateral/lateral.js"></script>
<script src="bower_components/ldsorgjs/ward.js"></script>
<script src="bower_components/ldsorgjs/stake.js"></script>
<script src="bower_components/ldsorgjs/browser.js"></script>
<script src="bower_components/ldsorgjs/ldsorg.js"></script>
<script src="bower_components/ldsorgjs/cache-browser.js"></script>
<script src="bower_components/chance/chance.js"></script>
<script src="bower_components/ldsorgjs/hogwarts.js"></script>

via download

wget http://ldsorg.github.io/ldsorgjs/ldsorg.all.js
<script src="ldsorg.all.js"></script>
<script src="bower_components/ldsorgjs/hogwarts.js"></script>
<script src="bower_components/ldsorgjs/hogwarts.js"></script>

Usage

In about 25 seconds you can download all of the data (including pictures) for your entire ward.

Note: You can log in as the user dumbledore with any password and have access to the fake stake Bettendorf from hogwarts.js.

;(function (exports) {
  'use strict';

  var LdsOrg = exports.LdsOrg || require('ldsorg').LdsOrg
      // you should probably create your own cache strategy
    , Cache = exports.LdsOrgCache || require('ldsorg/cache').LdsOrgCache
    , ldsorg
    , ts = Date.now()
    , username
    , password
    , isNode
    ;

  if ('undefined' !== typeof process && process.argv) {
    username = process.argv[2];
    password = process.argv[3];
    isNode = true;
  }

  ldsorg = LdsOrg.create({ node: isNode, Cache: Cache });

  // In the browser you must be already signed in
  ldsorg.signin(
    function (err) {
      console.log('sign-in complete');
      if (err) {
        console.log('failed', err);
        return;
      }

      ldsorg.init(
        function () {
          console.log('User Meta Data Gathered', ((Date.now() - ts) / 1000).toFixed(2) + 's');

          ldsorg.getCurrentStake().getAll(function () {
            console.log(
              'All stake-level data (not including wards) is now cached'
            , ((Date.now() - ts) / 1000).toFixed(2) + 's'
            );
          });
          ldsorg.getCurrentStake().getCurrentWard().getAll(function () {
            console.log(
              'All ward-level data is now cache'
            , ((Date.now() - ts) / 1000).toFixed(2) + 's'
            );
          });
        }
      , function log(event/*, a, b, c, d*/) {
          console.log('[LOG]', event);
          // build a nice big switch statement
        }
      , { node: isNode }
      );
    }
    // in node you must supply the user / pass to sign in
  , { username: username, password: password }
  );

}('undefined' !== typeof exports && exports || new Function('return this')()));

You should provide your own caching strategy with the same api as the provided cache.js or cache-browser.js.

API

TODO list respective urls and link to examples on ldsorg-api-documentation repo

LdsOrg

  • LdsOrg.create(opts) - returns an LdsOrg instance
  • #signin(cb, { username: 'u', password: 'p'}) - cb when signin is complete
    • cb is a function function (err) {}
    • auth is an object { username: 'johndoe', password: 'secret' }
  • #signout(cb)
  • #init(cb, emitFn) - cb when init is complete. emitFn(eventname, arg1, arg2, ...) for each event
  • #getCurrentUserId(fn)
  • #getCurrentUnits(fn)
  • #getCurrentStakes(fn)
  • #getCurrentUserMeta(fn)
  • #getCurrentHousehold(fn)
  • #getStake(stakeUnitNo) - returns an LdsStake instance
  • #getCurrentStake() - returns an LdsStake instance

Options

  • { prefetch: true } - start downloading the whole stake at init
    • current stake
    • current ward
    • other wards in stake
    • other stakes

LdsStake

  • LdsStake.create(opts, ldsOrg)
  • #getPositions(fn)
  • #getLeadership(fn, group)
  • #getWard(wardUnitNo) - returns an LdsWard instance
  • #getCurrentWard() - returns an LdsWard instance
  • #getWards(fn, wardsOrIds, opts)
  • #getAll(fn)

LdsWard

  • LdsWard.create(opts, ldsOrg, ldsStake) - called internally
  • #init(cb)
  • #getMemberList(fn)
  • #getPhotoList(fn)
  • #getOrganization(fn, orgname)
  • #getPositions(fn)
  • #getLeadership(fn, group)
  • #getHouseholdWithPhotos(fn, profileOrId, opts)
  • #getOrganizations(fn, orgnames)
  • #getCallings(fn)
  • #getHouseholds(fn, households, opts)
  • #getAll(fn, opts)
  • #getHousehold(fn, profileOrId)
  • #getHouseholdPhoto(fn, id)
  • #getIndividualPhoto(fn, id)

Build it yourself

mkdir -p bower_components
git clone [email protected]:FuturesJS/forAllAsync.git bower_components/forAllAsync
git clone [email protected]:FuturesJS/forEachAsync.git bower_components/forEachAsync
git clone [email protected]:FuturesJS/join.git bower_components/join
git clone [email protected]:FuturesJS/lateral.git bower_components/lateral
git clone [email protected]:LDSorg/ldsorgjs.git bower_components/ldsorgjs

cat \
  "bower_components/forAllAsync/forAllAsync.js" \
  "bower_components/forEachAsync/forEachAsync.js" \
  "bower_components/join/join.js" \
  "bower_components/lateral/lateral.js" \
  "bower_components/ldsorg/stake.js" \
  "bower_components/ldsorg/ward.js" \
  "bower_components/ldsorg/browser.js" \
  "bower_components/ldsorg/ldsorg.js" \
  "bower_components/ldsorg/cache-browser.js" \
  > ldsorg.all.js

TODO

Be able to serialize / deserialize top-level LdsOrg object so that it can be used between sessions for APIs.