js_util library
Cross-platform "dart:js_util" library.
Properties
- globalThis → Object
-
no setter
- objectPrototype → Object?
-
Returns the
Object
prototype. Equivalent toObject.prototype
.no setter
Functions
-
add<
T> (Object? first, Object? second) → T -
Perform JavaScript addition (
+
) on two values. -
allowInterop<
F extends Function> (F f) → F -
Returns a wrapper around function
f
that can be called from JavaScript usingpackage:js
JavaScript interop. -
allowInteropCaptureThis(
Function f) → Function -
Returns a wrapper around function
f
that can be called from JavaScript usingpackage:js
JavaScript interop, passing JavaScriptthis
as the first argument. -
and<
T> (Object? first, Object? second) → T -
Perform JavaScript logical and comparison (
&&
) of two expressions. -
callConstructor<
T> (Object constr, List< Object?> ? arguments) → T -
callMethod<
T> (Object o, Object method, List< Object?> args) → T -
createDartExport<
T extends Object> (T dartObject) → Object -
Given a Dart object that is marked exportable, creates a JS object literal
that forwards to that Dart class. Look at the
@JSExport
annotation to determine what constitutes "exportable" for a Dart class. The object literal will be a map of export names (which are either the written instance member names or their rename) to their respective Dart instance members. -
createStaticInteropMock<
T extends Object, U extends Object> (U dartMock, [Object? proto = null]) → T -
Given a
@staticInterop
type T and an instancedartMock
of a Dart class U that implements the external extension members of T, creates a forwarding mock. -
dartify(
Object? o) → Object? - Effectively the inverse of jsify, dartify Takes a JavaScript object, and converts it to a Dart based object. Only JS primitives, arrays, or 'map' like JS objects are supported.
-
delete<
T> (Object o, Object property) → bool -
Perform JavaScript delete operator (
delete
) on the given property of the given object. -
divide<
T> (Object? first, Object? second) → T -
Perform JavaScript division (
/
) on two values. -
equal<
T> (Object? first, Object? second) → bool -
Perform JavaScript equality comparison (
==
) on two values. -
exponentiate<
T> (Object? first, Object? second) → T -
Perform JavaScript exponentiation (
**
) on two values. -
getProperty<
T> (Object o, Object name) → T -
greaterThan<
T> (Object? first, Object? second) → bool -
Perform JavaScript greater than comparison (
>
) of two values. -
greaterThanOrEqual<
T> (Object? first, Object? second) → bool -
Perform JavaScript greater than or equal comparison (
>=
) of two values. -
hasProperty(
Object o, Object name) → bool -
instanceof(
Object? o, Object type) → bool -
Check whether
o
is an instance oftype
. -
instanceOfString(
Object? element, String objectType) → bool - Like instanceof only takes a String for the object name instead of a constructor object.
-
isJavaScriptArray(
dynamic value) → bool -
Returns
true
if a given object is a JavaScript array. -
isJavaScriptSimpleObject(
dynamic value) → bool -
Returns
true
if a given object is a simple JavaScript object. -
isTruthy<
T> (Object? o) → bool - Determines if the given object is truthy or falsy.
-
jsify(
Object? object) → dynamic - Recursively converts a JSON-like collection to JavaScript compatible representation.
-
lessThan<
T> (Object? first, Object? second) → bool -
Perform JavaScript less than comparison (
<
) of two values. -
lessThanOrEqual<
T> (Object? first, Object? second) → bool -
Perform JavaScript less than or equal comparison (
<=
) of two values. -
modulo<
T> (Object? first, Object? second) → T -
Perform JavaScript remainder (
%
) on two values. -
multiply<
T> (Object? first, Object? second) → T -
Perform JavaScript multiplication (
*
) on two values. -
newObject<
T> () → T -
not<
T> (Object? o) → T -
Perform JavaScript logical not (
!
) on the given object. -
notEqual<
T> (Object? first, Object? second) → bool -
Perform JavaScript inequality comparison (
!=
) on two values. -
objectGetPrototypeOf(
Object? object) → Object? -
Returns the prototype of a given object. Equivalent to
Object.getPrototypeOf
. -
objectKeys(
Object? object) → List< Object?> -
Returns the keys for a given object. Equivalent to
Object.keys(object)
. -
or<
T> (Object? first, Object? second) → T -
Perform JavaScript logical or comparison (
||
) of two expressions. -
promiseToFuture<
T> (Object jsPromise) → Future< T> - Converts a JavaScript Promise to a Dart Future.
-
setProperty<
T> (Object o, Object name, T? value) → T -
strictEqual<
T> (Object? first, Object? second) → bool -
Perform JavaScript strict equality comparison (
===
) on two values. -
strictNotEqual<
T> (Object? first, Object? second) → bool -
Perform JavaScript strict inequality comparison (
!==
) on two values. -
subtract<
T> (Object? first, Object? second) → T -
Perform JavaScript subtraction (
-
) on two values. -
typeofEquals<
T> (Object? o, String type) → bool -
Perform JavaScript
typeof
operator on the given object and determine if the result is equal to the given type. Exposes the wholetypeof
equal expression to maximize browser optimization. -
unsignedRightShift(
Object? leftOperand, Object? rightOperand) → num -
Perform JavaScript unsigned right shift operator (
>>>
) on the given left operand by the amount specified by the given right operand.
Exceptions / Errors
- NullRejectionException
-
Exception for when the promise is rejected with a
null
orundefined
value.