本文整理匯總了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)