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.7.0
  • 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

Basic Usage

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

  • 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

Node.js

Installation using Debian package

See Ubuntu Launchpad for details.

$ sudo add-apt-repository ppa:schnittstabil/node-char-buffer
$ sudo apt-get install node-char-buffer

Installation using Node Package Manager (npm)

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

  2. Install CharBuffer from NPM:

    npm install char-buffer
    

Examples

// 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

Installation

  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
    

Examples

<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>

Bower

Installation

  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
    

Examples using SystemJS

See systemjs/systemjs for details.

Install system.js:

bower install system.js
<script type="text/javascript" src="bower_components/traceur/traceur.js"></script>
<script type="text/javascript" src="bower_components/es6-module-loader/dist/es6-module-loader.js"></script>
<script type="text/javascript" src="bower_components/system.js/dist/system.js"></script>
<script type="module">
  import CharBuffer from 'bower_components/char-buffer/char-buffer';
  import TypedArrayBuffer from 'bower_components/char-buffer/typed-array-buffer';
  // Create the default CharBuffer implementation:
  var buffer = new CharBuffer(3);
  // Or create a specific CharBuffer implementation:
      buffer = new TypedArrayBuffer(3);

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

Examples using Browser Globals

<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>

Examples using Asynchronous Module Definition

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>

Changelog

  • v0.7.0

    • Remove componentjs support for legacy browsers
  • v0.6.2

  • v0.6.1

    • Fix: CharBuffer#fromString(string, [transform], [thisArg])
  • v0.6.0 char-buffer becomes more array-like

    • New: CharBuffer#map(callback, [thisArg])
    • New: CharBuffer#forEach(callback, [thisArg])
    • New: CharBuffer#fromString(string, [transform])
    • Fix: *Buffer.prototype.constructor
  • v0.5.0 component support

  • v0.4.0 char-buffer becomes more string-like

    • New: CharBuffer#charCodeAt(offset): CharCode
    • New: CharBuffer#charAt(offset): String
    • New: CharBuffer#length: Number
    • New: CharBuffer#read(offset): CharCode
    • New: CharBuffer#write(charCode, offset)

License

Copyright (c) 2014 Michael Mayer

Licensed under the MIT license.

Keywords

FAQs

Package last updated on 11 Sep 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