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

@flatfile/plugin-autocast

v6.0.1

Published

A plugin for automatically casting values in Flatfile.

Downloads

6,693

Readme

@flatfile/plugin-autocast

Automatically cast values in Flatfile to their appropriate types with this plugin.

The @flatfile/plugin-autocast plugin is an opinionated transformer that will automatically convert the data in the Sheet to match the type defined by the Blueprint.

Event Type: listener.on('commit:created')

Supported field types: number, boolean, date

Parameters

sheetSlug - string - (required)

The sheetSlug indicates the slug name of the sheet you want to monitor.

fieldFilters - string[]

Use the fieldFilters parameter to select specific fields to monitor. Without any specified fieldFilters, the plugin will automatically monitor all castable fields, including strings, numbers, booleans, and dates.

options.chunkSize - default: "10_000" - number

The chunkSize parameter allows you to specify the quantity of records to in each chunk.

options.parallel - default: "1" - number

The parallel parameter allows you to specify the number of chunks to process in parallel.

API Calls

  • api.sheets.get

Usage

The autocast plugin will listen for the commit:created event and cast strings, numbers, booleans, and dates to the appropriate Blueprint type. Note that the recordHook and bulkRecordHook plugins listen for the same event type. Plugins will fire in the order they are placed in the listener.

Strings

Numbers and booleans are transformed from strings to their respective types (i.e., '1' to 1, "true" to true).

Numbers

String numbers (i.e '1'), string decimals (i.e '1.1'), and string numbers with commas (i.e '1,000') are interpreted as numbers.

Booleans

'1', 'yes', 'true', 'on', 't', 'y', and 1 are interpreted as truthy values.

'-1', '0', 'no', 'false', 'off', 'f', 'n', 0, -1 are interpreted as falsy values.

Dates

Date strings and numbers are cast to UTC strings. For example, YYYY-MM-DD... formats are treated as ISO 8601 dates (UTC), whereas other formats are considered local time and converted to UTC:

  • '2023-08-16' => 'Wed, 16 Aug 2023 00:00:00 GMT'
  • '08-16-2023' => 'Wed, 16 Aug 2023 00:00:00 GMT'
  • '08/16/2023' => 'Wed, 16 Aug 2023 00:00:00 GMT'
  • 'Aug 16, 2023' => 'Wed, 16 Aug 2023 00:00:00 GMT'
  • 'August 16, 2023' => 'Wed, 16 Aug 2023 00:00:00 GMT'
  • '2023-08-16T00:00:00.000Z' => 'Wed, 16 Aug 2023 00:00:00 GMT'
  • 1692144000000 => 'Wed, 16 Aug 2023 00:00:00 GMT'

install

npm i @flatfile/plugin-autocast

import

import { autocast } from "@flatfile/plugin-autocast";

listener.js

listener.use(autocast("sheetSlug"));

listener.js w/ fieldFilters

listener.use(autocast("sheetSlug", ["numberField", "dateField"]));

listener.js w/ fieldFilters & options

listener.use(
  autocast("sheetSlug", ["numberField", "dateField"], {
    chunkSize: 10_000,
    parallel: 2,
  })
);