Skip to content

Commit

Permalink
Use const where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
MartijnCuppens authored and rlidwka committed Dec 7, 2020
1 parent 2b52d6e commit 2903b4f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -80,12 +80,12 @@ your own tags), see [wiki](https://github.com/nodeca/js-yaml/wiki) and
info.

``` javascript
yaml = require('js-yaml');
fs = require('fs');
const yaml = require('js-yaml');
const fs = require('fs');

// Get document, or throw exception on error
try {
var doc = yaml.safeLoad(fs.readFileSync('/home/ixti/example.yml', 'utf8'));
const doc = yaml.safeLoad(fs.readFileSync('/home/ixti/example.yml', 'utf8'));
console.log(doc);
} catch (e) {
console.log(e);
Expand Down Expand Up @@ -135,7 +135,7 @@ The core schema also has no such restrictions. It allows binary notation for int
must additionally validate object structure to avoid injections:

``` javascript
var untrusted_code = '"toString": !<tag:yaml.org,2002:js/function> "function (){very_evil_thing();}"';
const untrusted_code = '"toString": !<tag:yaml.org,2002:js/function> "function (){very_evil_thing();}"';

// I'm just converting that string, what could possibly go wrong?
require('js-yaml').load(untrusted_code) + ''
Expand All @@ -148,7 +148,7 @@ Same as `safeLoad()`, but understands multi-document sources. Applies
`iterator` to each document if specified, or returns array of documents.

``` javascript
var yaml = require('js-yaml');
const yaml = require('js-yaml');

yaml.safeLoadAll(data, function (doc) {
console.log(doc);
Expand Down

0 comments on commit 2903b4f

Please sign in to comment.