<commit_before>var write = require('../src/write'),
    fs = require('fs');

var points = [
    [0, 0],
    [10, 0],
    [10, 10],
    [-10, 10],
    [-10, -10]
];

var datas = [0, 1, 2, 3].map(function(_) { return { id: _ }; });

write(
    // feature data
    datas,
    // geometry type
    'POINT',
    // geometries
    points,
    finish);

function finish(err, files) {
    fs.writeFileSync('points.shp', toBuffer(files.shp.buffer));
    fs.writeFileSync('points.shx', toBuffer(files.shx.buffer));
    fs.writeFileSync('points.dbf', toBuffer(files.dbf.buffer));
}

function toBuffer(ab) {
    var buffer = new Buffer(ab.byteLength),
        view = new Uint8Array(ab);
    for (var i = 0; i < buffer.length; ++i) { buffer[i] = view[i]; }
    return buffer;
}<commit_msg>fix a bug in the example<commit_after>var write = require('../src/write'),
    fs = require('fs');

var points = [
    [0, 0],
    [10, 0],
    [10, 10],
    [-10, 10],
    [-10, -10]
];

var datas = [0, 1, 2, 3, 4].map(function(_) { return { id: _ }; });

write(
    // feature data
    datas,
    // geometry type
    'POINT',
    // geometries
    points,
    finish);

function finish(err, files) {
    fs.writeFileSync('points.shp', toBuffer(files.shp.buffer));
    fs.writeFileSync('points.shx', toBuffer(files.shx.buffer));
    fs.writeFileSync('points.dbf', toBuffer(files.dbf.buffer));
}

function toBuffer(ab) {
    var buffer = new Buffer(ab.byteLength),
        view = new Uint8Array(ab);
    for (var i = 0; i < buffer.length; ++i) { buffer[i] = view[i]; }
    return buffer;
}
{'fraction_non_alphanumeric': 0.1909323116219668, 'fraction_numerical': 0.030012771392081736, 'mean_word_length': 2.7577937649880098, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4176968', 'n_tokens_mistral': 613, 'n_tokens_neox': 572, 'n_words': 134}