New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dxf-parser

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dxf-parser - npm Package Compare versions

Comparing version 0.2.2 to 0.3.0

264

dist/dxf-parser.js

@@ -1,2 +0,2 @@

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.DxfParser = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.dxfParser = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
/**

@@ -396,6 +396,6 @@ * AutoCad files sometimes use an indexed color value between 1 and 255 inclusive.

// log.setLevel('debug');
log.setLevel('info');
//log.setLevel('info');
//log.setLevel('warn');
//log.setLevel('error');
//log.setLevel('silent');
log.setLevel('silent');

@@ -989,2 +989,6 @@

log.debug('}')
} else if(curr.value === 'POLYLINE') {
log.debug('POLYLINE {');
entities.push(parsePOLYLINE());
log.debug('}');
} else if(curr.value === 'LINE') {

@@ -1023,2 +1027,6 @@ log.debug('LINE {');

log.debug('}')
} else if(curr.value === 'ATTDEF') {
log.debug('ATTDEF {');
entities.push(parseATTDEF());
log.debug('}')
} else {

@@ -1111,2 +1119,63 @@ log.warn('Unhandled entity ' + curr.value);

var parseVertex = function() {
var entity = { type: curr.value },
numberOfVertices = 0;
curr = scanner.next();
while(curr !== 'EOF') {
if(curr.code === 0) break;
switch(curr.code) {
case 10: // X
entity.x = curr.value;
curr = scanner.next();
break;
case 20: // Y
entity.y = curr.value;
curr = scanner.next();
break;
case 30: // Z
entity.z = curr.value;
curr = scanner.next();
break;
case 40: // start width
case 41: // end width
case 42: // bulge
curr = scanner.next();
break;
case 70: // flags
entity.curveFittingVertex = (curr.value | 1) !== 0;
entity.curveFitTangent = (curr.value | 2) !== 0;
entity.splineVertex = (curr.value | 8) !== 0;
entity.splineControlPoint = (curr.value | 16) !== 0;
entity.ThreeDPolylineVertex = (curr.value | 32) !== 0;
entity.ThreeDPolylineMesh = (curr.value | 64) !== 0;
entity.polyfaceMeshVertex = (curr.value | 128) !== 0;
curr = scanner.next();
break;
case 50: // curve fit tangent direction
case 71: // polyface mesh vertex index
case 72: // polyface mesh vertex index
case 73: // polyface mesh vertex index
case 74: // polyface mesh vertex index
curr = scanner.next();
break;
default:
checkCommonEntityProperties(entity);
break;
}
}
return entity;
};
var parseSeqEnd = function() {
var entity = { type: curr.value };
curr = scanner.next();
while(curr != 'EOF') {
if (curr.code == 0) break;
checkCommonEntityProperties(entity);
}
return entity;
};
/**

@@ -1142,3 +1211,3 @@ * Parses a 2D or 3D point, returning it as an object with x, y, and

var parsePolylineVertices = function(n) {
var parsePolylinePoints = function(n) {
if(!n || n <= 0) throw Error('n must be greater than 0 verticies');

@@ -1164,2 +1233,17 @@ var vertices = [], i, vertex;

var parsePolylineVertices = function() {
var vertices = [];
while (curr !== 'EOF') {
if (curr.code === 0) {
if (curr.value === 'VERTEX') {
vertices.push(parseVertex());
} else if (curr.value === 'SEQEND') {
parseSeqEnd();
break;
}
}
}
return vertices;
};
var parseMTEXT = function() {

@@ -1207,2 +1291,113 @@ var entity = { type: curr.value };

var parseATTDEF = function() {
var entity = {
type: curr.value,
scale: 1,
textStyle: 'STANDARD'
};
curr = scanner.next();
while (curr !== 'EOF') {
if (curr.code === 0) {
break;
}
switch(curr.code) {
case 1:
entity.text = curr.value;
curr = scanner.next();
break;
case 2:
entity.tag = curr.value;
curr = scanner.next();
break;
case 3:
entity.prompt = curr.value;
curr = scanner.next();
break;
case 7:
entity.textStyle = curr.value;
curr = scanner.next();
break;
case 10:
entity.x = curr.value;
curr = scanner.next();
break;
case 20:
entity.y = curr.value;
curr = scanner.next();
break;
case 30:
entity.z = curr.value;
curr = scanner.next();
break;
case 39:
entity.thickness = curr.value;
curr = scanner.next();
break;
case 40:
entity.textHeight = curr.value;
curr = scanner.next();
break;
case 41:
entity.scale = curr.value;
curr = scanner.next();
break;
case 50:
entity.rotation = curr.value;
curr = scanner.next();
break;
case 51:
entity.obliqueAngle = curr.value;
curr = scanner.next();
break;
case 70:
entity.invisible = !!(curr.value & 0x01);
entity.constant = !!(curr.value & 0x02);
entity.verificationRequired = !!(curr.value & 0x04);
entity.preset = !!(curr.value & 0x08);
curr = scanner.next();
break;
case 71:
entity.backwards = !!(curr.value & 0x02);
entity.mirrored = !!(curr.value & 0x04);
curr = scanner.next();
break;
case 72:
// TODO: enum values?
entity.horizontalJustification = curr.value;
curr = scanner.next();
break;
case 73:
entity.fieldLength = curr.value;
curr = scanner.next();
break;
case 74:
// TODO: enum values?
entity.verticalJustification = curr.value;
curr = scanner.next();
break;
case 100:
// subclass
curr = scanner.next();
break;
case 210:
entity.extrusionDirectionX = curr.value;
curr = scanner.next();
break;
case 220:
entity.extrusionDirectionY = curr.value;
curr = scanner.next();
break;
case 230:
entity.extrusionDirectionZ = curr.value;
curr = scanner.next();
break;
default:
checkCommonEntityProperties(entity);
break;
}
}
return entity;
};
/**

@@ -1231,3 +1426,3 @@ * Called when the parser reads the beginning of a new entity,

case 10: // X coordinate of point
entity.vertices = parsePolylineVertices(numberOfVertices);
entity.vertices = parsePolylinePoints(numberOfVertices);
break;

@@ -1244,2 +1439,59 @@ default:

* Called when the parser reads the beginning of a new entity,
* 0:POLYLINE. Scanner.next() will return the first attribute of the
* entity.
* @return {Object} the entity parsed
*/
var parsePOLYLINE = function() {
var entity = { type: curr.value, vertices: [] },
numberOfVertices = 0;
curr = scanner.next();
while(curr !== 'EOF') {
if(curr.code === 0) break;
switch(curr.code) {
case 10: // always 0
case 20: // always 0
case 30: // elevation
case 39: // thickness
case 40: // start width
case 41: // end width
curr = scanner.next();
break;
case 70: // 1 = Closed shape, 128 = plinegen?, 0 = default
entity.shape = (curr.value | 1) !== 0;
curr = scanner.next();
break;
case 71: // Polygon mesh M vertex count
case 72: // Polygon mesh N vertex count
case 73: // Smooth surface M density
case 74: // Smooth surface N density
case 75: // Curves and smooth surface type
curr = scanner.next();
break;
case 210: // X extrusion direction
log.debug(curr.value);
curr = scanner.next();
break;
case 220: // Y extrusion direction
case 230: // Z extrusion direction
curr = scanner.next();
break;
case 100: // Subclass marker
log.debug(scanner.value);
checkCommonEntityProperties(entity);
break;
default:
checkCommonEntityProperties(entity);
break;
}
}
entity.vertices = parsePolylineVertices();
return entity;
};
/**
* Called when the parser reads the beginning of a new entity,
* 0:LINE. Scanner.next() will return the first attribute of the

@@ -1257,3 +1509,3 @@ * entity.

case 10: // X coordinate of point
entity.vertices = parsePolylineVertices(2);
entity.vertices = parsePolylinePoints(2);
break;

@@ -1260,0 +1512,0 @@ case 100:

@@ -8,6 +8,6 @@ var DxfArrayScanner = require('./DxfArrayScanner.js'),

// log.setLevel('debug');
log.setLevel('info');
//log.setLevel('info');
//log.setLevel('warn');
//log.setLevel('error');
//log.setLevel('silent');
log.setLevel('silent');

@@ -601,2 +601,6 @@

log.debug('}')
} else if(curr.value === 'POLYLINE') {
log.debug('POLYLINE {');
entities.push(parsePOLYLINE());
log.debug('}');
} else if(curr.value === 'LINE') {

@@ -635,2 +639,6 @@ log.debug('LINE {');

log.debug('}')
} else if(curr.value === 'ATTDEF') {
log.debug('ATTDEF {');
entities.push(parseATTDEF());
log.debug('}')
} else {

@@ -723,2 +731,63 @@ log.warn('Unhandled entity ' + curr.value);

var parseVertex = function() {
var entity = { type: curr.value },
numberOfVertices = 0;
curr = scanner.next();
while(curr !== 'EOF') {
if(curr.code === 0) break;
switch(curr.code) {
case 10: // X
entity.x = curr.value;
curr = scanner.next();
break;
case 20: // Y
entity.y = curr.value;
curr = scanner.next();
break;
case 30: // Z
entity.z = curr.value;
curr = scanner.next();
break;
case 40: // start width
case 41: // end width
case 42: // bulge
curr = scanner.next();
break;
case 70: // flags
entity.curveFittingVertex = (curr.value | 1) !== 0;
entity.curveFitTangent = (curr.value | 2) !== 0;
entity.splineVertex = (curr.value | 8) !== 0;
entity.splineControlPoint = (curr.value | 16) !== 0;
entity.ThreeDPolylineVertex = (curr.value | 32) !== 0;
entity.ThreeDPolylineMesh = (curr.value | 64) !== 0;
entity.polyfaceMeshVertex = (curr.value | 128) !== 0;
curr = scanner.next();
break;
case 50: // curve fit tangent direction
case 71: // polyface mesh vertex index
case 72: // polyface mesh vertex index
case 73: // polyface mesh vertex index
case 74: // polyface mesh vertex index
curr = scanner.next();
break;
default:
checkCommonEntityProperties(entity);
break;
}
}
return entity;
};
var parseSeqEnd = function() {
var entity = { type: curr.value };
curr = scanner.next();
while(curr != 'EOF') {
if (curr.code == 0) break;
checkCommonEntityProperties(entity);
}
return entity;
};
/**

@@ -754,3 +823,3 @@ * Parses a 2D or 3D point, returning it as an object with x, y, and

var parsePolylineVertices = function(n) {
var parsePolylinePoints = function(n) {
if(!n || n <= 0) throw Error('n must be greater than 0 verticies');

@@ -776,2 +845,17 @@ var vertices = [], i, vertex;

var parsePolylineVertices = function() {
var vertices = [];
while (curr !== 'EOF') {
if (curr.code === 0) {
if (curr.value === 'VERTEX') {
vertices.push(parseVertex());
} else if (curr.value === 'SEQEND') {
parseSeqEnd();
break;
}
}
}
return vertices;
};
var parseMTEXT = function() {

@@ -819,2 +903,113 @@ var entity = { type: curr.value };

var parseATTDEF = function() {
var entity = {
type: curr.value,
scale: 1,
textStyle: 'STANDARD'
};
curr = scanner.next();
while (curr !== 'EOF') {
if (curr.code === 0) {
break;
}
switch(curr.code) {
case 1:
entity.text = curr.value;
curr = scanner.next();
break;
case 2:
entity.tag = curr.value;
curr = scanner.next();
break;
case 3:
entity.prompt = curr.value;
curr = scanner.next();
break;
case 7:
entity.textStyle = curr.value;
curr = scanner.next();
break;
case 10:
entity.x = curr.value;
curr = scanner.next();
break;
case 20:
entity.y = curr.value;
curr = scanner.next();
break;
case 30:
entity.z = curr.value;
curr = scanner.next();
break;
case 39:
entity.thickness = curr.value;
curr = scanner.next();
break;
case 40:
entity.textHeight = curr.value;
curr = scanner.next();
break;
case 41:
entity.scale = curr.value;
curr = scanner.next();
break;
case 50:
entity.rotation = curr.value;
curr = scanner.next();
break;
case 51:
entity.obliqueAngle = curr.value;
curr = scanner.next();
break;
case 70:
entity.invisible = !!(curr.value & 0x01);
entity.constant = !!(curr.value & 0x02);
entity.verificationRequired = !!(curr.value & 0x04);
entity.preset = !!(curr.value & 0x08);
curr = scanner.next();
break;
case 71:
entity.backwards = !!(curr.value & 0x02);
entity.mirrored = !!(curr.value & 0x04);
curr = scanner.next();
break;
case 72:
// TODO: enum values?
entity.horizontalJustification = curr.value;
curr = scanner.next();
break;
case 73:
entity.fieldLength = curr.value;
curr = scanner.next();
break;
case 74:
// TODO: enum values?
entity.verticalJustification = curr.value;
curr = scanner.next();
break;
case 100:
// subclass
curr = scanner.next();
break;
case 210:
entity.extrusionDirectionX = curr.value;
curr = scanner.next();
break;
case 220:
entity.extrusionDirectionY = curr.value;
curr = scanner.next();
break;
case 230:
entity.extrusionDirectionZ = curr.value;
curr = scanner.next();
break;
default:
checkCommonEntityProperties(entity);
break;
}
}
return entity;
};
/**

@@ -843,3 +1038,3 @@ * Called when the parser reads the beginning of a new entity,

case 10: // X coordinate of point
entity.vertices = parsePolylineVertices(numberOfVertices);
entity.vertices = parsePolylinePoints(numberOfVertices);
break;

@@ -856,2 +1051,59 @@ default:

* Called when the parser reads the beginning of a new entity,
* 0:POLYLINE. Scanner.next() will return the first attribute of the
* entity.
* @return {Object} the entity parsed
*/
var parsePOLYLINE = function() {
var entity = { type: curr.value, vertices: [] },
numberOfVertices = 0;
curr = scanner.next();
while(curr !== 'EOF') {
if(curr.code === 0) break;
switch(curr.code) {
case 10: // always 0
case 20: // always 0
case 30: // elevation
case 39: // thickness
case 40: // start width
case 41: // end width
curr = scanner.next();
break;
case 70: // 1 = Closed shape, 128 = plinegen?, 0 = default
entity.shape = (curr.value | 1) !== 0;
curr = scanner.next();
break;
case 71: // Polygon mesh M vertex count
case 72: // Polygon mesh N vertex count
case 73: // Smooth surface M density
case 74: // Smooth surface N density
case 75: // Curves and smooth surface type
curr = scanner.next();
break;
case 210: // X extrusion direction
log.debug(curr.value);
curr = scanner.next();
break;
case 220: // Y extrusion direction
case 230: // Z extrusion direction
curr = scanner.next();
break;
case 100: // Subclass marker
log.debug(scanner.value);
checkCommonEntityProperties(entity);
break;
default:
checkCommonEntityProperties(entity);
break;
}
}
entity.vertices = parsePolylineVertices();
return entity;
};
/**
* Called when the parser reads the beginning of a new entity,
* 0:LINE. Scanner.next() will return the first attribute of the

@@ -869,3 +1121,3 @@ * entity.

case 10: // X coordinate of point
entity.vertices = parsePolylineVertices(2);
entity.vertices = parsePolylinePoints(2);
break;

@@ -872,0 +1124,0 @@ case 100:

2

package.json
{
"name": "dxf-parser",
"version": "0.2.2",
"version": "0.3.0",
"description": "Parse dxf files into a readable, logical js object.",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc