DefinitelyTyped/types/shpjs/index.d.ts
Hsiao-Ting Yu 18a45cd318 Add definition for shpjs (#30525)
* Add type definition for shpjs

* Fix shpjs definition: fileName should be optional.
2018-11-18 19:25:00 -08:00

30 lines
1.4 KiB
TypeScript

// Type definitions for shpjs 3.4
// Project: https://github.com/calvinmetcalf/shapefile-js#readme
// Definitions by: Hsiao-Ting Yu <https://github.com/littlebtc>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node" />
/// <reference types="geojson" />
declare namespace shpjs {
// All toBuffer() compatible buffers.
type ShpJSBuffer = Buffer | ArrayBuffer | { buffer: ArrayBuffer };
interface FeatureCollectionWithFilename extends GeoJSON.FeatureCollection {
fileName?: string;
}
interface ShpJS {
(base: string | ShpJSBuffer, whiteList?: ReadonlyArray<string>): Promise<FeatureCollectionWithFilename | FeatureCollectionWithFilename[]>;
parseZip(buffer: ShpJSBuffer, whiteList?: ReadonlyArray<string>): Promise<FeatureCollectionWithFilename | FeatureCollectionWithFilename[]>;
getShapeFile(base: string | ShpJSBuffer, whiteList?: ReadonlyArray<string>): Promise<FeatureCollectionWithFilename | FeatureCollectionWithFilename[]>;
combine(arr: [ReadonlyArray<GeoJSON.Geometry>, ReadonlyArray<GeoJSON.GeoJsonProperties>]): GeoJSON.FeatureCollection;
parseShp(shp: ShpJSBuffer, prj: string | Buffer): GeoJSON.Geometry[];
parseDbf(dbf: ShpJSBuffer, cpg: ShpJSBuffer): GeoJSON.GeoJsonProperties[];
}
}
declare var shpjs: shpjs.ShpJS;
export = shpjs;