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

char-buffer

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

char-buffer

Collect CharCodes and convert them to string.

  • 0.5.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2K
decreased by-9.67%
Maintainers
1
Weekly downloads
 
Created
Source

char-buffer Dependencies Status Image Build Status Image Coverage Status Built with Grunt

Collect CharCodes and convert them to a string.

Selenium Test Status

Installation

Node Package Manager (npm)

  1. Install node.js (npm comes with node).

  2. Install CharBuffer from NPM:

    npm install char-buffer
    

Component

  1. Install node.js (npm comes with node).

  2. Install component:

    npm install component --global
    
  3. Create component.json:

    {
      "name": "getting-started",
      "dependencies": {
        "schnittstabil/char-buffer": "*"
      }
    }
    
  4. Install dependencies:

    component install
    
  5. Run build

    component build
    

Bower

  1. Install node.js (npm comes with node).

  2. Install Bower:

    npm install bower --global
    
  3. Install CharBuffer from bower.io:

    bower install char-buffer
    

Basic Usage

CharBuffer provides multiple implementations to collect CharCodes via a common interface (CharBuffer.CharBuffer):

  • CharBuffer.StringBuffer uses a single String
  • CharBuffer.StringArrayBuffer uses an Array of Strings
  • CharBuffer.TypedArrayBuffer uses an Uint16Array
  • CharBuffer.NodeBuffer uses a Node.js Buffer
var buffer;

// Create the default CharBuffer of your platform:
buffer = new CharBuffer();

// Same as before, but provide an estimate of the length of your string:
buffer = new CharBuffer(3);

// Create a specific CharBuffer implementation, if supported:
if(CharBuffer.TypedArrayBuffer.isSupported)
  buffer = new CharBuffer.TypedArrayBuffer(3);
}


// Append a CharCode:
buffer.append(102);

// Append two more CharCodes:
buffer.append(111).append(111);

// Output 'foo':
console.log(buffer.toString());

Documentations

Examples

Node.js

// Create the default CharBuffer implementation:
var CharBuffer = require('char-buffer'),
    buffer     = new CharBuffer(3);

// Or create a specific CharBuffer implementation by CharBuffer:
var CharBuffer       = require('char-buffer'),
    TypedArrayBuffer = CharBuffer.TypedArrayBuffer,
    buffer           = new TypedArrayBuffer(3);

// Or create a specific CharBuffer implementation by package:
var TypedArrayBuffer = require('char-buffer/typed-array-buffer'),
    buffer           = new TypedArrayBuffer(3);


// Output 'foo':
console.log(buffer.append(102).append(111).append(111).toString());

Component

<script src="build/build.js"></script>
<script>

// Create the default CharBuffer implementation:
var CharBuffer = require('char-buffer'),
    buffer = new CharBuffer(3);

// Or create a specific CharBuffer implementation:
var CharBuffer = require('char-buffer'),
    TypedArrayBuffer = CharBuffer.TypedArrayBuffer,
    buffer           = new TypedArrayBuffer(3);


// Output 'foo'
console.log(buffer.append(102).append(111).append(111).toString());

</script>

Browser Globals (using Bower)

<script src="bower_components/char-buffer/char-buffer.global.js"></script>
<script>

// Create the default CharBuffer implementation:
var buffer = new CharBuffer(3);

// Or create a specific CharBuffer implementation:
var TypedArrayBuffer = CharBuffer.TypedArrayBuffer,
    buffer           = new TypedArrayBuffer(3);


// Output 'foo'
console.log(buffer.append(102).append(111).append(111).toString());

</script>

Asynchronous Module Definition (using Bower)

See Asynchronous Module Definition (AMD) for details.

<script src="path/to/your/amd/loader.js"></script>
<script src="bower_components/char-buffer/char-buffer.amd.js"></script>
<script>

/**
 * Use the CharBuffer package:
 */
require(['char-buffer'], function(CharBuffer){
  // create the default CharBuffer implementation:
  var buffer = new CharBuffer(3);

  // Or create a specific CharBuffer implementation by CharBuffer:
  var TypedArrayBuffer = CharBuffer.TypedArrayBuffer,
      buffer = new TypedArrayBuffer(3);


  // Output 'foo'
  console.log(buffer.append(102).append(111).append(111).toString());
});


/**
  * Or use a specific CharBuffer package:
  */
require(['char-buffer/typed-array-buffer'], function(TypedArrayBuffer){

  var buffer = new TypedArrayBuffer(3);

  // Output 'foo'
  console.log(buffer.append(102).append(111).append(111).toString());
});

</script>

License

Copyright (c) 2014 Michael Mayer

Licensed under the MIT license.

Keywords

FAQs

Package last updated on 23 May 2014

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