One Hat Cyber Team
Your IP :
10.30.1.1
Server IP :
103.148.201.5
Server :
Linux web-olt 5.15.0-161-generic #171-Ubuntu SMP Sat Oct 11 08:17:01 UTC 2025 x86_64
Server Software :
Apache/2.4.52 (Ubuntu)
PHP Version :
8.1.29
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
doc
/
node-js-yaml
/
examples
/
Edit File:
handle_unknown_types.js
'use strict'; /*eslint-disable no-console*/ const util = require('util'); const yaml = require('../'); class CustomTag { constructor(type, data) { this.type = type; this.data = data; } } const tags = [ 'scalar', 'sequence', 'mapping' ].map(function (kind) { // first argument here is a prefix, so this type will handle anything starting with ! return new yaml.Type('!', { kind: kind, multi: true, representName: function (object) { return object.type; }, represent: function (object) { return object.data; }, instanceOf: CustomTag, construct: function (data, type) { return new CustomTag(type, data); } }); }); const SCHEMA = yaml.DEFAULT_SCHEMA.extend(tags); const data = ` subject: Handling unknown types in JS-YAML scalar: !unknown_scalar_tag foo bar sequence: !unknown_sequence_tag [ 1, 2, 3 ] mapping: !unknown_mapping_tag { foo: 1, bar: 2 } `; const loaded = yaml.load(data, { schema: SCHEMA }); console.log('Parsed as:'); console.log('-'.repeat(70)); console.log(util.inspect(loaded, false, 20, true)); console.log(''); console.log(''); console.log('Dumped as:'); console.log('-'.repeat(70)); console.log(yaml.dump(loaded, { schema: SCHEMA }));
Simpan