本文整理汇总了TypeScript中load-json-file.sync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript sync函数的具体用法?TypeScript sync怎么用?TypeScript sync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sync函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: require
import * as path from 'path'
import * as flatten from '../'
const load = require('load-json-file')
const multiPolygon: GeoJSON.Feature<GeoJSON.MultiPolygon> = load.sync(path.join(__dirname, 'in', 'MultiPolygon.geojson'))
flatten(multiPolygon);
const geometryCollection: GeoJSON.GeometryCollection = load.sync(path.join(__dirname, 'in', 'GeometryCollection.geojson'))
flatten(geometryCollection);
示例2: assert
/// <reference path="load-json-file.d.ts" />
import * as loadJsonFile from 'load-json-file';
function assert(actual: string, expected: string): void {
if (actual !== expected) {
throw new Error(`${JSON.stringify(actual)} !== ${JSON.stringify(expected)}`);
}
}
loadJsonFile('../package.json').then(pkg => {
assert(pkg.name, 'definitely-typed');
});
const pkg = loadJsonFile.sync('../package.json');
assert(pkg.name, 'definitely-typed');
示例3: require
import * as lineSegment from '../'
import * as path from 'path'
const load = require('load-json-file')
const polygon: GeoJSON.Feature<GeoJSON.Polygon> = load.sync(path.join(__dirname, 'in', 'polygon.geojson'));
// Test Types
lineSegment(polygon)