Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dxfom/text

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dxfom/text - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

7

index.d.ts

@@ -11,2 +11,7 @@ export interface DxfTextContentElement {

}
export declare const parseDxfTextContent: (text: string) => DxfTextContentElement[];
export declare const decodeDxfTextCharacterCodes: (text: string, mbcsEncoding?: string | TextDecoder | undefined) => string;
export declare const decodeDxfTextUnicodeCodePoints: (text: string) => string;
export declare const decodeDxfTextMbcsCharacterCodes: (text: string, encoding: string | TextDecoder) => string;
export declare const parseDxfTextContent: (text: string, options?: {
readonly encoding?: string | TextDecoder | undefined;
} | undefined) => DxfTextContentElement[];

@@ -21,4 +21,20 @@ // https://knowledge.autodesk.com/ja/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2019/JPN/AutoCAD-Core/files/GUID-968CBC1D-BA99-4519-ABDD-88419EB2BF92-htm.html

export const parseDxfTextContent = (text: string): DxfTextContentElement[] => {
text = text.replace(/\\[uU]\+([0-9a-fA-F]{4})/g, (_, codePoint) => String.fromCodePoint(parseInt(codePoint, 16)))
export const decodeDxfTextCharacterCodes = (text: string, mbcsEncoding?: string | TextDecoder) => {
text = decodeDxfTextUnicodeCodePoints(text)
return mbcsEncoding ? decodeDxfTextMbcsCharacterCodes(text, mbcsEncoding) : text
}
export const decodeDxfTextUnicodeCodePoints = (text: string) =>
text.replace(/\\[uU]\+([0-9a-fA-F]{4})/g, (_, codePoint) => String.fromCodePoint(parseInt(codePoint, 16)))
export const decodeDxfTextMbcsCharacterCodes = (text: string, encoding: string | TextDecoder) => {
let decoder: TextDecoder | undefined = encoding instanceof TextDecoder ? encoding : undefined
return text.replace(
/\\[mM]\+1([0-9a-fA-F]{2})([0-9a-fA-F]{2})/g,
(_, a, b) => (decoder = decoder || new TextDecoder(encoding as string)).decode(new Uint8Array([parseInt(a, 16), parseInt(b, 16)]))
)
}
export const parseDxfTextContent = (text: string, options?: { readonly encoding?: string | TextDecoder }): DxfTextContentElement[] => {
text = decodeDxfTextCharacterCodes(text, options?.encoding)
let previousIndex = 0

@@ -25,0 +41,0 @@ let currentContent: DxfTextContentElement = { text: '' }

6

package.json
{
"name": "@dxfom/text",
"version": "0.1.0",
"version": "0.2.0",
"description": "A low level DXF TEXT content parser.",

@@ -16,5 +16,5 @@ "license": "GPL-3.0",

"devDependencies": {
"terser": "^4.6.10",
"typescript": "^3.8.3"
"terser": "^5.5.1",
"typescript": "^4.1.3"
}
}

Sorry, the diff of this file is not supported yet

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