@mapbox/mvt-fixtures
Advanced tools
Comparing version 3.8.0 to 3.9.0
@@ -0,1 +1,5 @@ | ||
## 3.9.0 | ||
* Add `create` method to module, allowing inline fixtures to be created for faster iteration in downstream libraries. | ||
## 3.8.0 | ||
@@ -2,0 +6,0 @@ |
18
index.js
@@ -91,5 +91,19 @@ 'use strict'; | ||
/** | ||
* Create a tile buffer inline without referencing a pre-existing fixture | ||
* | ||
* @param {Object} definition - the JSON-style protocol buffer instructions | ||
* @param {Object} [options] | ||
* @param {string} [options.proto="2.1"] - optional vector tile spec version | ||
*/ | ||
function create(definition, options) { | ||
if (!definition) throw new Error('No definition provided to mvt-fixtures#create method.'); | ||
options = options || {}; | ||
return { | ||
buffer: generateBuffer(definition, options.proto || '2.1', options) | ||
} | ||
} | ||
module.exports = { | ||
get: get, | ||
each: each | ||
get, each, create | ||
}; |
{ | ||
"name": "@mapbox/mvt-fixtures", | ||
"version": "3.8.0", | ||
"version": "3.9.0", | ||
"description": "A require-able test fixture suite of valid and invalid Mapbox Vector Tiles", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -45,2 +45,32 @@ ![mvt-fixtures crew](https://c1.staticflickr.com/5/4495/24124229798_b82cd97858_o.png) | ||
const output = decoder(mvtf.get('043').buffer); | ||
// or you can build a fixture inline | ||
const { buffer } = mvtf.create({ | ||
layers: [ | ||
{ | ||
version: 2, | ||
name: 'parks', | ||
features: [ | ||
{ | ||
id: 10, | ||
tags: [ 0, 0 ], // name: Stanley Park | ||
type: 1, // point | ||
geometry: [ 9, 54, 38 ] | ||
}, | ||
{ | ||
id: 10, | ||
tags: [ 0, 0 ], // name: Olympic | ||
type: 1, // point | ||
geometry: [ 9, 2, 5 ] | ||
} | ||
], | ||
keys: [ 'name' ], | ||
values: [ | ||
{ string_value: 'Stanley Park' }, | ||
{ string_value: 'Olympic' } | ||
], | ||
extent: 4096 | ||
} | ||
] | ||
}); // ==> Buffer() | ||
``` | ||
@@ -47,0 +77,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
32843010
521
6891
201