GithubHelp home page GithubHelp logo

js-yaml-js-types's Introduction

js-yaml-js-types

CI NPM version

js-yaml extra types:

  • !!js/regexp /pattern/gim
  • !!js/undefined ''
  • !!js/function 'function () {...}'

Installation

npm install js-yaml-js-types

Usage

const yaml = require('js-yaml');
const unsafe = require('js-yaml-js-types').all;

const schema = yaml.DEFAULT_SCHEMA.extend(unsafe);

const src = `
- !!js/regexp /pattern/gim
- !!js/undefined ''
- !!js/function 'function () { return true }'
`

yaml.load(src, { schema });

js-yaml-js-types's People

Contributors

puzrin avatar rlidwka avatar ronaldjerez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

js-yaml-js-types's Issues

Publish module

Hello.

Please, publish the module on npmjs.org.

image

I can't install it by command in README.md

npm install js-yaml-js-types

failed in mjs file

import yaml, { Type } from 'js-yaml'
import { all, regexp } from 'js-yaml-js-types'

console.log(regexp instanceof Type, typeof regexp, regexp)

const schema = yaml.DEFAULT_SCHEMA.extend(regexp);

const src = `
- !!js/regexp /pattern/g
- !!js/undefined ''
- !!js/function 'function () { return true }'
`

const parse = () => {
  console.log(yaml.load(src, { schema }))
}

get error

YAMLException: Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })

and regexp instanceof Type is false

YAMLException: Specified list of YAML types (or a single Type object) contains a non-Type object

I encountered a YAMLException problem

ERROR {
  err: YAMLException: Specified list of YAML types (or a single Type object) contains a non-Type object.
      at C:\Users\MrTT\Desktop\test112\node_modules\@jiangtj\hexo-next-pwa\node_modules\js-yaml\lib\schema.js:104:13
      at Array.forEach (<anonymous>)
      at Schema.extend (C:\Users\MrTT\Desktop\test112\node_modules\@jiangtj\hexo-next-pwa\node_modules\js-yaml\lib\schema.js:102:12)
      at C:\Users\MrTT\Desktop\test112\node_modules\@jiangtj\hexo-next-pwa\index.js:13:36
      at C:\Users\MrTT\Desktop\test112\node_modules\hexo\lib\hexo\index.js:305:14
      at tryCatcher (C:\Users\MrTT\Desktop\test112\node_modules\bluebird\js\release\util.js:16:23)
      at Promise._settlePromiseFromHandler (C:\Users\MrTT\Desktop\test112\node_modules\bluebird\js\release\promise.js:547:31)
      at Promise._settlePromise (C:\Users\MrTT\Desktop\test112\node_modules\bluebird\js\release\promise.js:604:18)
      at Promise._settlePromise0 (C:\Users\MrTT\Desktop\test112\node_modules\bluebird\js\release\promise.js:649:10)
      at Promise._settlePromises (C:\Users\MrTT\Desktop\test112\node_modules\bluebird\js\release\promise.js:729:18)
      at _drainQueueStep (C:\Users\MrTT\Desktop\test112\node_modules\bluebird\js\release\async.js:93:12)
      at _drainQueue (C:\Users\MrTT\Desktop\test112\node_modules\bluebird\js\release\async.js:86:9)
      at Async._drainQueues (C:\Users\MrTT\Desktop\test112\node_modules\bluebird\js\release\async.js:102:5)
      at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\MrTT\Desktop\test112\node_modules\bluebird\js\release\async.js:15:14)
      at processImmediate (internal/timers.js:456:21) {
    reason: 'Specified list of YAML types (or a single Type object) contains a non-Type object.',
    mark: undefined
  }
}

But it’s strange that the code I introduced is the same as the example

In my code index.js:13:36

image

Reproduction

yarn global add hexo
hexo init adir
cd adir
yarn add @jiangtj/hexo-next-pwa@beta
hexo g

async function not supprted?

I'm try to write async !!js/function like
data: !!js/function async function () { return await myFunction() }

or

data: !!js/function async () => await myFunction()

but get an exception:

SyntaxError: await is only valid in async function

Are async function supported?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.