
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
angular-types
Advanced tools
AngularJS introspection utilities
AngularJS ships with various functions to check types, such as angular.isNumber()
, angular.isUndefined()
, and angular.isElement()
. This extension adds many functions to AngularJS' builtins, including a general-purpose type-checking function and a cloning function.
This is particularly useful if you want the type-checking functionality of Lo-Dash or Underscore, but without the libraries themselves. Many of these functions were derived from Lo-Dash implementations.
Each of these functions accept a value and return a boolean.
isNull()
/ isNotNull()
isBoolean()
/ isNotBoolean()
isNaN()
/ isNotNaN()
isFinite()
/ isNotFinite()
isInfinite()
/ isNotInfinite()
isArguments()
/ isNotArguments()
isRegExp()
/ isNotRegExp()
isEmpty()
/ isNotEmpty()
isInteger()
/ isNotInteger()
isFloat()
/ isNotFloat()
isObjectish()
/ isNotObjectish()
(returns true
if the value is not null
and may contain properties)In addition, the negation of the AngularJS built-ins are provided:
isNotUndefined()
isNotArray()
isNotDate()
isNotElement()
isNotObject()
isNotString()
isNotFunction()
isNotNumber()
type()
The type()
function will accept a value and return one of the following strings:
null
, string
, array
, date
, regexp
, arguments
, boolean
, number
, undefined
, function
, element
, object
An
element
is considered to be a DOM node, jqLite object, or jQuery object.
clone()
The clone()
function will return a deep clone of some value. This differs from angular.copy()
in the following ways:
destination
parameter.clone()
function, that function will be called. This is useful for complex nested objects.angular.copy()
internally so your $$hashKey
s are not befouled.extra
, which can be extended onto the clone. This is useful, for example, if you have a unique identifier in an object, and wish to re-generate it.In the browser, if not using AMD, the functions are attached to the angular
object as to not further pollute the global scope.
var foo = {
bar: 1,
baz: function() {
return this.bar + 1;
}
};
angular.isInteger(foo.bar); // true
angular.type(foo.bar); // 'number'
angular.isNotFunction(foo.baz); // false
angular.type(foo.baz); // 'function'
// example of using second parameter
angular.clone(foo, {bar: 2}).baz(); // 3
In a NodeJS context, require()
the angular-types
module.
var types = require('angular-types'),
quux = 1;
types.isInteger(quux);
Using RequireJS, just require types
.
define(['/path/to/types'], function(types) {
var quux = 1;
types.isInteger(quux);
});
If using in NodeJS (a la Browserify):
npm install angular-types
Otherwise, use Bower:
bower install angular-types
Copyright © 2014 Decipher, Inc. Licensed MIT
FAQs
AngularJS introspection utilities
The npm package angular-types receives a total of 66 weekly downloads. As such, angular-types popularity was classified as not popular.
We found that angular-types demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.