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

win-clipboard

v0.0.6

Published

Clipboard access for Windows.

Downloads

12

Readme

win-clipboard NPM version Build Status Dependency Status

An experimental Node.js module that provides you a full control over host clipboard in Windows environment.

Installation

If you haven't ever messed up with C++ addons, you'll have most likely to install windows-build-tools. It takes a fair amount of time to complete, but simplifies the installation by a lot.

npm install --global --production windows-build-tools

Once you have the above, it's as simple as:

npm install --save win-clipboard

Usage

const clipboard = require( 'win-clipboard' );

clipboard.getText(); // Returns unicode format as a string.

clipboard.getHTML(); // Returns HTML as a string.

clipboard.getData( 'HTML Format' ); // Returns raw content of a "HTML Format".

clipboard.setText( '🙀🙊' ); // Sets some fancy emoji in your unicode format.

clipboard.getFormats(); // Lists formats in the clipboard.

API

  • getText( [format, encoding] )
    • Params:
      • format - string - Format name you want to set. Could be one of the standard builtins. Examples are CF_UNICODETEXT, CF_TEXT, HTML Format etc. Defaults to CF_UNICODETEXT.
      • encoding - string - Encoding used for decoding string in the clipboard. Defaults to utf-16le.
    • Returns:
      • string - String retrieved from the clipboard.
      • null - If no data was found.
  • setText( newText[, format, encoding] )
    • Params:
      • newText - string - Text to be set in the clipboard.
      • format - string - Format name you want to set. Could be one of the standard builtins. Examples are CF_UNICODETEXT, CF_TEXT, HTML Format etc. Defaults to CF_UNICODETEXT.
      • encoding - string - Encoding used for encoding string into the clipboard. Default value depends on format:
        • CF_TEXT - Defaults to ascii.
        • CF_UNICODETEXT - Defaults to utf-16le.
        • In any other case defaults to utf8.
    • Returns:
      • number - Number of bytes written if successful.
      • null - If failed.
  • getHTML( [fullHtml, format] )
    • Params:
      • fullHtml - boolean - If set to true will return outer context, like html, body tags. Defaults to false.
      • format - string - Format name you want to set. Could be one of the standard builtins. Examples are CF_UNICODETEXT, CF_TEXT, HTML Format etc.
  • setHTML( newHtml, [sourceUrl, format] )
    • Params:
      • newHtml - string - HTML code to be set.
      • sourceUrl - string - URL to be set as a SourceURL header. Defaults to null.
      • format - string - Format name you want to set. Could be one of the standard builtins. Examples are CF_UNICODETEXT, CF_TEXT, HTML Format etc.
  • getData( format )
    • Params:
      • format - string - Format name you want to set. Could be one of the standard builtins. Examples are CF_UNICODETEXT, CF_TEXT, HTML Format etc.
    • Returns:
      • Buffer - A raw buffer of what is kept in the memory.
      • null - If nothing is found.
  • setData( newData, format ) - Sets raw data to a given clipboard format.
    • Params:
      • newData - ArrayBuffer - Raw data to be set.
      • format - string - Format name you want to set. Could be one of the standard builtins. Examples are CF_UNICODETEXT, CF_TEXT, HTML Format etc.
    • Returns:
      • number - Number of bytes written if successful.
      • null - If failed.
  • getFormats
    • Returns:
      • string[] - An array of strings with available formats.
  • clear - Simply wipes out your clipboard.

Why?

I needed to put some fancy stuff into a clipboard, and I was surprised that there's no good library for managing the clipboard.

What I needed was an ability to set HTML / RTF / plain text together, which was nowhere to be found.

Other requirement that I had in other side project, was retrieve all the formats in clipboard, for a further inspection.

All the implementation allowed just for setting a plaintext - it was due to the fact that it was based on clip bin.

How?

I implemented it using a Node.js C++ addon, which uses WinAPI.

The implementation turned out to be extremely easy, while having access to the WinAPI it gives all the power in the world to work with the clipboard.

License

MIT © Marek Lewandowski