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

typed-array

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typed-array

  • 0.1.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= typed-array

Gem provides enforced-type functionality to Arrays

Copyright (c) 2011 Ryan Biesemeyer See LICENSE.txt for details

Ryan Biesemeyer mailto:ruby-dev@yaauie.com

== Example

=== Create Standard Class

require 'typed-array' class Things < Array extend TypedArray restrict_types Thing1,Thing2 end

=== Generate Class using Factory

require 'typed-array' things = TypedArray(Thing1,Thing2)

=== Adding items to the Array

All standard Array interfaces are implemented, including block-processing

and variable-number of arguments. For methods that would usually return an

Array, they instead return an instance of the current class (except to_a).

The difference is that if the method would generate an Array including the

wrong types, TypedArray::UnexpectedTypeException is raised and the call is

aborted before modifying the enforced TypedArray instance.

require 'typed-array' symbols = TypedArray(Symbol).new([:foo,:bar,:baz,:bingo]) begin integers = TypedArray(Integer).new([1,3,7,2,:symbol]) rescue TypedArray::UnexpectedTypeException puts "An error occured: #{$!}" end

FAQs

Package last updated on 03 Aug 2011

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