Adding functions to a loaded node.js module -
about 2 years ago, wrote node.js module loads existing module (jsts) , adds functions it. here minimal example:
global.jsts = require("jsts"); global.jsts.algorithm.test = function() {console.log("hi")} global.jsts.algorithm.test();
i ran in node (v0.10.18) , printed
hi
now, run same code in nodejs (v4.2.6) , prints:
typeerror: global.jsts.algorithm.test not function
is there way make work current version of nodejs?
edit: did:
global.jsts.algorithm.x = 1 console.log(global.jsts.algorithm)
and here output:
{ centroid: { [function: ge] area2: [function], centroid3: [function], getcentroid: [function] }, cgalgorithms: { [function: he] orientationindex: [function], signedarea: [function], distancelineline: [function], ispointinring: [function], computelength: [function], isccw: [function], locatepointinring: [function], distancepointlineperpendicular: [function], computeorientation: [function], distancepointline: [function], isonline: [function], clockwise: -1, right: -1, counterclockwise: 1, left: 1, collinear: 0, straight: 0 }, convexhull: { [function: me] extractcoordinates: [function], radialcomparator: { [function: ye] polarcompare: [function] } }, interiorpointarea: { [function: oi] centre: [function], avg: [function], safebisectorfinder: { [function: ai] getbisectory: [function] } }, interiorpointline: [function: ui], interiorpointpoint: [function: li], robustlineintersector: { [function: ae] nearestendpoint: [function] }, mcpointinring: { [function: ii] mcselecter: [function: ni] }, minimumboundingcircle: { [function: wi] pointwitminanglewithx: [function], lowestpoint: [function], pointwithminanglewithsegment: [function] }, minimumdiameter: { [function: li] nextindex: [function], computec: [function], getminimumdiameter: [function], getminimumrectangle: [function], computesegmentforline: [function] } }
Comments
Post a Comment