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

gulp-once

v2.1.1

Published

Only pass through files once until changed

Downloads

2,007

Readme

gulp-once

NPM Version Build Status

Only pass through files once unless changed

Similar to plugins such as gulp-cache, gulp-changed, and gulp-newer, except it doesn't care about your dest/build files and it will still persist your "cache" (unless you don't want it to) across Gulp runs. Also makes it easy to manage what files are filtered since data is stored in a easily readable JSON file.

Install

$ npm install gulp-once --save-dev

Usage

var gulp = require('gulp'),
    once = require('gulp-once'),
    someExpensiveOperation = require('some-expensive-operation');

gulp.task('default', function() {

    gulp.src('src/**/*')
        .pipe(once()),
        .pipe(someExpensiveOperation())
        .pipe(gulp.dest('dest'));
});

Options

    gulp.src('src/**/*')
        .pipe(once({
            context: process.cwd(),
            namespace: false,
            algorithm: 'sha1',
            file: '.checksums',
            fileIndent: 4
        })),
        .pipe(someExpensiveOperation())
        .pipe(gulp.dest('dest'));

options.context

[string|boolean]: Sets the path used for calculating all files' relative path, which is then used as the hash key in your checksums file. If you only wish to store filenames without their path, you can set this option to false. Default: process.cwd()

    gulp.src('src/img/*')
        .pipe(once('images')),
        .pipe(someExpensiveOperation())
        .pipe(gulp.dest('dest/img'));

options.namespace

[string|function|boolean]: If you want to separate pools/namespaces of hashes for different tasks within the same checksums file, you can assign a namespace for a specific stream. You can also provide a function that dynamically sets the namespace per file—this function will be passed a copy of the file vinyl file object being checked. Default: false

If you do not pass an object as an option to once(), it will be passed to this setting.

    gulp.src('src/img/*')
        .pipe(once('images')),
        .pipe(someExpensiveOperation())
        .pipe(gulp.dest('dest/img'));

options.algorithm

[string]: Whatever you would want passed to crypto.createHash() Default: 'sha1'

options.file

[string|boolean]: Path to file to persist data as JSON between Gulp runs. Is useful for retaining file details if Gulp exits unexpectedly and you have to restart, if you run tasks manually (i.e. You don't gulp.watch() files), or to just not run unnecessary actions between work sessions. Also allows you to easily "cache bust" for specific files easily if you are so inclined. Can be set to false to store data in memory, this effectively turns off persistance as a file will not be created/updated with any file changes. Default: '.checksums'

    gulp.src('src/img/*')
        .pipe(once({file: 'path/to/file.json'})),
        .pipe(someExpensiveOperation())
        .pipe(gulp.dest('dest/img'));

options.fileIndent

[int]: If you're a stickler for spacing on your files, you can set the indentation for the checksumed files. Has no effect if options.file is set to false. Default: 4