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 🙏

© 2026 – Pkg Stats / Ryan Hefner

lite-gas-simulator

v0.1.0

Published

Lightweight local simulator for Google Apps Script – mock SpreadsheetApp, CacheService and more using JSON data sources

Readme

lite-gas-simulator

Lightweight local simulator for Google Apps Script. Develop and test your GAS server code without clasp push.

What it does

Mocks all GAS globals (SpreadsheetApp, CacheService, PropertiesService, Logger, Session, Utilities, MailApp, HtmlService) against local data sources so your server functions run unmodified on your machine.

Install

npm install lite-gas-simulator --save-dev

Quick Start

1. Create mock data

Create a directory with one JSON file per sheet. Each file is a 2D array where the first row is headers:

mock-data/
├── users.json
└── products.json
// mock-data/users.json
[
  ["id", "name", "email"],
  ["1", "Alice", "[email protected]"],
  ["2", "Bob", "[email protected]"]
]

2. Create and use the simulator

import { createSimulator } from 'lite-gas-simulator';
import { DataStore } from 'gas-react-core/server';

const sim = createSimulator({
  dataDir: './mock-data',
});

// Injects SpreadsheetApp, CacheService, etc. into globalThis
sim.installGlobals();

// Now your server code works locally!
const users = DataStore.getAll('users');
console.log(users);
// [{ id: '1', name: 'Alice', email: '[email protected]' }, ...]

3. Start a dev server (optional)

If your frontend uses executeFn with __GAS_DEV_MODE__, start the companion HTTP server:

sim.startDevServer({
  port: 3001,
  functions: {
    getUsers: () => DataStore.getAll('users'),
    addUser: (user) => DataStore.insert('users', user),
  },
});

Your React app's executeFn('getUsers') calls will hit localhost:3001/api/getUsers and execute against mock data.

Data Sources

JSON directory (recommended)

const sim = createSimulator({
  dataDir: './mock-data', // directory of .json files
});

Each .json file = one sheet. Filename (without extension) = sheet name.

API

createSimulator(options?)

| Option | Type | Description | | -------------------- | -------- | ------------------------------------------ | | dataDir (required) | string | Path to directory of JSON files | | userEmail | string | Email for Session.getActiveUser() mock | | timeZone | string | Timezone for Session.getScriptTimeZone() | | disableAutoPersist | boolean| Set true to skip auto-flushing to disk |

Returns a Simulator object:

| Method | Description | | ------------------ | ---------------------------------------------------- | | installGlobals() | Set all GAS mocks on globalThis | | removeGlobals() | Clean up globalThis | | persist() | Manually flush in-memory data to JSON (auto by default) | | startDevServer() | Start HTTP dev server for frontend executeFn calls | | sheets | The raw Map<string, unknown[][]> data | | mocks | Direct access to all mock objects |

createDevServer(options)

| Option | Type | Default | Description | | ----------- | ----------------------------------------------------- | ------- | ------------------------ | | port | number | 3001 | Port to listen on | | functions | Record<string, (...args: unknown[]) => unknown> | — | Server function registry | | cors | boolean | true | Enable CORS headers | | verbose | boolean | true | Log requests to console |

Individual mock factories

All mocks can be used standalone for unit testing:

import {
  createSpreadsheetAppMock,
  createCacheServiceMock,
  createPropertiesServiceMock,
  createLoggerMock,
  createSessionMock,
  createUtilitiesMock,
  createMailAppMock,
  createHtmlServiceMock,
} from 'lite-gas-simulator';

Persistence

By default, every mutation auto-persists to the JSON files on disk. When your code calls appendRow, setValues, deleteRow, or insertSheet, the changes are immediately written back to the corresponding .json file in dataDir.

This means data survives process restarts — no manual save step needed.

To disable auto-persist (e.g. for performance in bulk operations):

const sim = createSimulator({
  dataDir: './mock-data',
  disableAutoPersist: true,
});

// ... do bulk mutations ...
sim.persist(); // flush manually when ready

Use in Tests

import { describe, it, beforeEach, afterEach } from 'vitest';
import { createSimulator } from 'gas-simulator';
import { DataStore } from 'gas-react-core/server';

describe('my server functions', () => {
  let sim;

  beforeEach(() => {
    // Point to a test-data directory with JSON files
    sim = createSimulator({
      dataDir: './test-data',
    });
    sim.installGlobals();
  });

  afterEach(() => {
    sim.removeGlobals();
  });

  it('getAll returns users', () => {
    const users = DataStore.getAll('users');
    expect(users).toHaveLength(1);
    expect(users[0].name).toBe('Alice');
  });
});

License

MIT