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 🙏

© 2025 – Pkg Stats / Ryan Hefner

srvsyn

v1.0.3

Published

A library to execute serversided JavaScript functions from the client!

Readme

How it works

As a web developer you often find yourself writing APIs for your client. Extracting the data, managing accesslevels and executing the code you want can challenge the structure of your program. This means you losing time. When you use srvsyn, you can execute functions on your server as if they were executed on your client. Just call the function and wait for the response.

Installation

$ npm install srvsyn

Sample

Server

The setup is simple and straight forward. Set up an express server, define your functions and initialize.

The initialization function has three parameters:

  • express app - the application, on which srvsyn is running.
  • external authentication function (not required) - a function to return an authentication level, when the sent authentication token is unknown. This can be used to look for the authentication token in a database.
  • config (not required) - Consists of two properties (execPath, initPath), which can be set if the default srvsyn urls conflict with others.
var express = require('express');
var server = require('./srvsyn');

var app = express();
app.use("/", express.static(__dirname + "/src"))

server.access[0].helloWorld = function(name)
{
    return "Hello world from " + name + "!";
}

server.access[0].login = function()
{
    this.authenticate(1);
}

server.access[1].secureHelloWorld = function(name)
{
    return "Secure hello world from " + name + "!";
}

server.initialize(app, function(token) 
{
    return 0;
});

app.listen(80);

Client

Include the client library:

<html>
    <head>
        ...
        <script src="client.srvsyn.js"></script>
        ...
    </head>
    ...
<html>

Any initialization is done automatically. You can now use the functions you defined on your server. By default the accesslevel is 0. Before the client can use the function secureHelloWorld it must have at least an accesslevel of 1.

A client does not know that a function exists, when it is not authenticated to use it. When used anyways, it will not find the function.

Any JavaScript on the client:

console.log(server.helloWorld('hurray')); //Expected output: Hello world from hurray!
server.login();
console.log(server.secureHelloWorld('hurray')); //Expected output: Secure hello world from hurray!