Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cop

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cop

Filter stream

  • 0.2.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22
decreased by-46.34%
Maintainers
1
Weekly downloads
 
Created
Source

cop - filter stream

Build Status

Description

A through Stream, configurable to emit specific properties of objects written to it. Furthermore, if provided with a filter function, cop can be used to modulate data.

Usage

Property key

var cop = require('cop')
  , es = require('event-stream')
  , fstream = require('fstream')
  , reader = fstream.Reader({ path:process.cwd() })

reader.pipe(cop('path')).pipe(es.writeArray(function (err, paths) {
  console.log(paths)
}))

Filter function

var cop = require('cop')
  , fstream = require('fstream')
  , reader = fstream.Reader({ path:process.cwd() })

reader.pipe(cop(filter)).pipe(process.stdout)

function filter (obj) {
  return obj ? obj['path'] + '\n' : undefined
}

Signature

cop(key)

Provided a key, cop will emit the matching property of an object written to it. If the object has no matching property nothing is emitted.

cop(filter)

Alternatively a filter function can be provided, which is executed before data is emitted, hence, provides an opportunity to massage the data.

Events

See Stream

Installation

Install with npm:

npm install cop

License

MIT License

Keywords

FAQs

Package last updated on 12 Apr 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc