CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-tns-platform-declarations

Platform-specific TypeScript declarations for NativeScript for accessing native objects

84

1.23x
Overview
Eval results
Files

task.mdevals/scenario-1/

Native Object Memory Manager

A utility module for managing memory when working with native platform objects in NativeScript applications. This module helps prevent memory leaks by properly releasing native object references and triggering garbage collection when needed.

Capabilities

Release Native Object References

Implement a function that explicitly releases native object references to free up memory. The function should handle both Android and iOS native objects.

  • Given a native object, the function releases its native counterpart and returns true @test
  • Given a null or undefined value, the function returns false without throwing an error @test
  • Given a JavaScript object with no native counterpart, the function returns false @test

Trigger Garbage Collection

Implement a function that triggers garbage collection on the appropriate platform to reclaim memory from released native objects.

  • When called on Android, the function triggers garbage collection and returns the platform name "android" @test
  • When called on iOS, the function triggers garbage collection and returns the platform name "ios" @test

Batch Memory Cleanup

Implement a function that processes an array of native objects, releasing each one and then triggering garbage collection. The function should return statistics about the cleanup operation.

  • Given an array of native objects, the function releases all objects and returns an object with count of successful releases @test
  • Given an empty array, the function returns an object with zero successful releases and still triggers garbage collection @test

Implementation

@generates

API

/**
 * Releases the native counterpart of a native object.
 *
 * @param obj - The native object to release
 * @returns true if the object was released successfully, false otherwise
 */
export function releaseNativeObject(obj: any): boolean;

/**
 * Triggers garbage collection on the current platform.
 *
 * @returns The platform name ("android" or "ios")
 */
export function triggerGarbageCollection(): string;

/**
 * Performs batch cleanup of native objects by releasing each one
 * and triggering garbage collection.
 *
 * @param objects - Array of native objects to release
 * @returns Statistics object with successfulReleases count
 */
export function batchCleanup(objects: any[]): { successfulReleases: number };

Dependencies { .dependencies }

tns-platform-declarations { .dependency }

Provides TypeScript declarations for NativeScript platform APIs including memory management functions.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-tns-platform-declarations

tile.json