From 51ac7b7575bd046ea8fef9c19fcd0fec7f3ea718 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 4 Apr 2017 07:58:49 -0700 Subject: [PATCH] xml-js: Provides its own types --- notNeededPackages.json | 6 +++ types/xml-js/index.d.ts | 82 ------------------------------------ types/xml-js/tsconfig.json | 22 ---------- types/xml-js/xml-js-tests.ts | 48 --------------------- 4 files changed, 6 insertions(+), 152 deletions(-) delete mode 100644 types/xml-js/index.d.ts delete mode 100644 types/xml-js/tsconfig.json delete mode 100644 types/xml-js/xml-js-tests.ts diff --git a/notNeededPackages.json b/notNeededPackages.json index 274f8f829b..5379649358 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -384,6 +384,12 @@ "sourceRepoURL": "https://code.google.com/p/x2js/", "asOfVersion": "3.1.0" }, + { + "libraryName": "xml-js", + "typingsPackageName": "xml-js", + "sourceRepoURL": "https://github.com/nashwaan/xml-js", + "asOfVersion": "1.0.0" + }, { "libraryName": "@xmpp/jid", "typingsPackageName": "xmpp-jid", diff --git a/types/xml-js/index.d.ts b/types/xml-js/index.d.ts deleted file mode 100644 index eb89067c86..0000000000 --- a/types/xml-js/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -// Type definitions for xml-js 0.9.6 -// Project: https://github.com/nashwaan/xml-js -// Definitions by: Denis Carriere -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -export interface ElementCompact { - [key: string]: any - _attributes?: { - [key: string]: number | number - } - _cdata?: string | number - _comment?: string | number - _declaration?: { - _attributes?: { - version?: string | number - encoding?: string | number - } - } - _text?: string | number -} - -export interface Element { - attributes?: { - [key: string]: string | number - } - cdata?: string | number - comment?: string | number - declaration?: { - attributes?: { - version: string | number - encoding: string | number - } - } - elements?: Array - text?: string | number - type?: string | number - name?: string | number -} - -declare namespace Options { - interface XML2JS extends ChangingKeyNames, IgnoreOptions { - compact?: boolean - spaces?: number | string - trim?: boolean - sanitize?: boolean - nativeType?: boolean - addParent?: boolean - alwaysChildren?: boolean - } - - interface JS2XML extends ChangingKeyNames, IgnoreOptions { - spaces?: number | string - compact?: boolean - fullTagEmptyElement?: boolean - } - - interface IgnoreOptions { - ignoreDeclaration?: boolean - ignoreAttributes?: boolean - ignoreComment?: boolean - ignoreCdata?: boolean - ignoreText?: boolean - } - - interface ChangingKeyNames { - declarationKey?: string - attributesKey?: string - textKey?: string - cdataKey?: string - commentKey?: string - parentKey?: string - typeKey?: string - nameKey?: string - elementsKey?: string - } -} - -export function js2xml(json: Element | ElementCompact, options?: Options.JS2XML): string; -export function json2xml(json: Element | ElementCompact, options?: Options.JS2XML): string; -export function xml2json(xml: string, options?: Options.XML2JS): any; -export function xml2js(xml: string, options?: Options.XML2JS): any; - diff --git a/types/xml-js/tsconfig.json b/types/xml-js/tsconfig.json deleted file mode 100644 index 09b2ed9cff..0000000000 --- a/types/xml-js/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "xml-js-tests.ts" - ] -} \ No newline at end of file diff --git a/types/xml-js/xml-js-tests.ts b/types/xml-js/xml-js-tests.ts deleted file mode 100644 index d437ee14f4..0000000000 --- a/types/xml-js/xml-js-tests.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { Element, ElementCompact } from 'xml-js' -import * as convert from 'xml-js' - -// Declaration -const declarationCompact1: ElementCompact = { _declaration: { _attributes: { version: 2 } }}; -const declarationCompact2: ElementCompact = { _declaration: { _attributes: { version: '1.0', encoding: 'utf-8' }}}; -const declaration1: Element = { declaration: { }}; -const declaration2: Element = { declaration: { attributes: { version: '1.0', encoding: 'utf-8' }}}; - -// Comment -const commentCompact: ElementCompact = { _comment : 'Hello, World!' }; -const comment: Element = { elements: [{ type: 'comment', comment: 'Hello, World!' }]}; - -// CDATA -const cdataCompact: ElementCompact = { _cdata: '' }; -const cdata: Element = { elements : [{ type: 'cdata', cdata: '' }]}; - -// Element -const elementCompact1: ElementCompact = { a: {} }; -const element1: Element = { elements:[{ type: 'element', name: 'a' }]}; - -const elementCompact2: ElementCompact = { a: { _attributes: { x: '1.234', y:'It\'s' }}}; -const element2: Element = { elements: [{ type: 'element', name: 'a', attributes: { x: '1.234', y: 'It\'s' }}]}; - -const elementCompact3: ElementCompact = { a: { _text: ' Hi ' }}; -const element3: Element = { elements:[{ type: 'element', name: 'a', elements: [{ type: 'text', text: ' Hi ' }]}]}; - -const elementCompact4: ElementCompact = { a: {}, b: {} }; -const element4: Element = { elements:[{ type: 'element', name: 'a' }, { type: 'element', name: 'b' }]}; - -const elementCompact5: ElementCompact = { a: { b: {} }}; -const element5: Element = { elements: [{ type: 'element', name: 'a', elements: [{ type: 'element', name: 'b' }]}]}; - -// xml2json -const xml = ` - - - Happy - Work - Play -`; -convert.xml2json(xml, { compact: true, spaces: 4 }); -convert.xml2json(xml, { compact: false }); - -// json2xml -convert.json2xml({ a: {} }, { compact: true, spaces: 4 }); -convert.json2xml({ elements:[{ type: 'element', name: 'a' }]}, { compact: false }); -