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

@psychoscope/jspsych

v0.0.14

Published

This npm package overloads [jspsych 7.3.4](https://www.jspsych.org/v7/) with two novel behaviors.

Downloads

3

Readme

psychoscope-jspsych

This npm package overloads jspsych 7.3.4 with two novel behaviors.

Novel behavior 1: automatically post data to an endpoint

If a task using psychoscope-jspsych is loaded with a query parameter connection_url, it will post data there, as well as start and end messages. If no such query parameter is provided, this does not occur, and jsPsych behaves normally.

Here are the times in which the client will post to the connection_url:

  1. On page load, the client will post a "START" event to the connection_url with body:

    {
      "event_code": "START",
      "event_timestamp": "<ISO8601-formatted UTC timestamp>"
    }
  2. Whenever the jsPsych on_data_update callback is triggered (i.e. at the end of each jsPsych plugin trial), it will post a "REPORT" event containing the stringified data object to that endpoint, using body:

    {
      "event_code": "REPORT",
      "event_data": "<stringified trial object>",
      "event_timestamp": "<ISO8601-formatted UTC timestamp>"
    }
  3. When the timeline on_finish callback is executed, the client will post a request with an empty body to the connection_url, with body:

    {
      "event_code": "END",
      "event_timestamp": "<ISO8601-formatted UTC timestamp>"
    }

See the src/server-communication/conn.ts file for a simple Express server which receives events under the protocol above.

The server may optionally send back JSON responses of the form:

type PostEventResponse = {
   message?: string,
   redirect_url?: string,
}

If message is provided, the client will log it to the console. If redirect_url is provided following the transmission of an END event, the client will redirect to that URL (see below).

Novel behavior 2: automatic redirection

Following the conclusion of the jsPsych timeline (and after the base on_timeline_finish handler concludes), the client will redirect if it receives a JSON response from the server with a redirect_url field (see above).

Building

To actually build the above jspsych.js file from source, cd to the psychoscope-jspsych directory and run:

  1. npm install
  2. npm run build

The resultant, built file will be located in psychoscope-jspsych/dist/psychoscope/jspsych/7.3.4/jspsych.js.

Local jest testing instructions

The jest test server-communication.test.js runs a simple client locally that automatically traverses the jsPsych timeline with timeline.simulate. This tests that a client using psychoscope-jspsych successfully follow the protocol outlined above.

  1. cd psychoscope-jspsych, then install the package using npm install.
  2. Run npm run test. This builds the package, then runs jest.