Remove Node outside the view

I am new with GOJS

Is there any way to remove nodes that are partially in the view
I want that if a node is partially in or out of the view then it should be removed

Diagram.viewportBounds describes the rectangle that is in the view.

You can find all objects inside of a rectangle using Diagram.findObjectsIn().

You could make a collection of all objects not in that collection, and then remove it from the diagram with Diagram.removeParts().

@simon sory but it didnt work for me
I am doing like this
var check=$scope.myDiagram.viewportBounds
var test=$scope.myDiagram.findObjectsIn(check);
then I am expecting test.count to be my number of nodes in the view

It should work, that is, something like this:

myDiagram.findObjectsIn(myDiagram.viewportBounds).count;

Will return the count of every object you can see.

This will find every part:

myDiagram.findObjectsIn(myDiagram.viewportBounds, function(x) { return x.part; }).count;