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

asana-cache-local

v1.3.2

Published

cache tasks within an asana workspace, locally

Downloads

10

Readme

Codeship Status for cdaringe/asana-cache-local

asana-cache-local

cache all tasks within an asana workspace, onto your local machine. caches only tasks that have been assigned. tasks are all stored in a single NoSQL store. cache.refresh() uses the asana incrimental API, and only pulls down updates on tasks since they have last been modified, or new tasks since the store has last been updated. :)

// example
var asana = require('asana');
var client = asana.Client.create().useBasicAuth('your-api-key');
var Cacher = require('asana-cache-local');
var cacher = new Cache({
    client: client,
    workspace: 123456789,
    verbose: true
});
var log = function() { console.dir(arguments); };

cacher.refresh()
    .then(function() {
        cacher.tasks.all().then(log); // show all tasks!
        cacher.users.all().then(log); // show all users!
    });

api

constructor // new Cacher(opts)

  • @param {object} opts
  • @option {number} workspace - id of tasks to cache
  • @option {object} client - asana api client, with authorization set
  • @options {string=} dbpath - folder to store local database dbs/caches
  • @option {boolean=} verbose - enable logging of non-error/warning events
    • @default undefined
  • @option {string=} fields to include in task. must be formatted (kind of goofyish, as done with the @default below)
    • @default 'completed,completed_at,created_at,due_on,assignee_status,modified_at,parent,notes,name'

properties

  • @property tasks - Pouchy datastore of asana tasks
  • @property users - Pouchy of asana users

methods

refresh

Downloads all of the assigned tasks from the workspace, user-by-user, and stores them in a local db. On subsequent calls, tasks fetched that are new/updated are only recieved from the point of last update (so it speeds up after first run).

  • @return {proimse}
  • @resolves {undefined}

loadUsersToCache()

Loads the users onto the cache for ease of access. Users can be accessed via cacher.cache.users (array), or cacher.cache.usersById (object indexed by user id)

  • @return {promise}
  • @resolves {array} list of users
var promise1 = cacher.tasks.all();
var promise2 = cacher.loadUsersToCache();
Promise.all([promise1, promise2]).then(function assignNamesToAssignees(r) {
    var tasks = r[0];
    var users = r[1];
    tasks.forEach(function(task) {
        /* cacher.cache.usersById = {
         *    12345678: 'bill brasky',
         *    ...
         * }
         */
        task.assignmeeName = cacher.cache.usersById[task.assignee];
    });
})