🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@11ty/gray-matter

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@11ty/gray-matter - npm Package Compare versions

Comparing version
2.0.1
to
2.0.2
+8
-11
lib/stringify.js
'use strict';
const typeOf = require('kind-of');
const getEngine = require('./engine');
const defaults = require('./defaults');
const { isObject } = require('./utils');
module.exports = function(file, data, options) {
if (data == null && options == null) {
switch (typeOf(file)) {
case 'object':
data = file.data;
options = {};
break;
case 'string':
return file;
default: {
throw new TypeError('expected file to be a string or object');
}
if (isObject(file)) {
data = file.data;
options = {};
} else if (typeof file === 'string') {
return file;
} else {
throw new TypeError('expected file to be a string or object');
}

@@ -20,0 +17,0 @@ }

'use strict';
const typeOf = require('kind-of');
const stringify = require('./stringify');

@@ -13,7 +12,7 @@ const utils = require('./utils');

module.exports = function(file) {
if (typeOf(file) !== 'object') {
if (!utils.isObject(file)) {
file = { content: file };
}
if (typeOf(file.data) !== 'object') {
if (!utils.isObject(file.data)) {
file.data = {};

@@ -20,0 +19,0 @@ }

'use strict';
const stripBom = require('strip-bom-string');
const typeOf = require('kind-of');

@@ -23,2 +21,4 @@ exports.define = function(obj, key, val) {

const toString = Object.prototype.toString;
/**

@@ -29,3 +29,3 @@ * Returns true if `val` is an object

exports.isObject = function(val) {
return typeOf(val) === 'object';
return toString.call(val) === '[object Object]';
};

@@ -48,2 +48,9 @@

function stripBom(str) {
return (typeof str === 'string' && str.charAt(0) === '\ufeff') ?
str.slice(1) :
str;
}
/**

@@ -50,0 +57,0 @@ * Cast `val` to a string.

{
"name": "@11ty/gray-matter",
"description": "Parse front-matter from a string or file. Fast, reliable and easy to use. Parses YAML front matter by default, but also has support for YAML, JSON, TOML Front-Matter, with options to set custom delimiters. Used by metalsmith, assemble, verb and many other projects.",
"version": "2.0.1",
"version": "2.0.2",
"homepage": "https://github.com/11ty/gray-matter",

@@ -39,5 +39,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"js-yaml": "^4.1.1",
"kind-of": "^6.0.3",
"section-matter": "^1.0.0",
"strip-bom-string": "^1.0.0"
"section-matter": "^1.0.0"
},

@@ -44,0 +42,0 @@ "devDependencies": {