title: Store and index YAML with PostgreSQL, with Javascript lib or reusable functions?
body: <p><a href="http://www.postgresql.org/" rel="nofollow">PostgreSQL</a> 9.2 has native JSON support. I'd like to store human readable config files, however, in YAML. And I think I'd like to index a few (but not all) of the config file values. Therefore I'm wondering:</p>
  
  <ol>
  <li>Is it's somehow possible to include [a third party Javascript library that parses Yaml] in Postgres, for example <a href="https://github.com/nodeca/js-yaml" rel="nofollow">js-yaml</a>. Then I could have my own YAML Javascript helper, in the same way as there's the built-in JSON helper in PostgreSQL 9.2.</li>
  </ol>
  
  <p>Alternatively:</p>
  
  <ol>
  <li><p>is it possible to declare individual reusable Javascript functions? If so, then I could add my own YAML parsing functions (based on simple regexps), that are able to parse a subset of YAML, for example the top level key-value pairs here:</p>
  
  <pre><code># some "top level key-value paris":
  the_key: 'the value'
  another_key: 'another value'
  # But this however:
  would_be_too_complicated_to_parse_manually_with_regexps: |
    block string
    with newlines
  </code></pre></li>
  </ol>
  
  <p>Worst case scenario would be that I'd need to duplicate YAML parsing code in each PostgreSQL stored procedure (if I cannot add 3rd party libraries or declare reusable functions).</p>
  
  <p>(Performance wouldn't be terribly important in my case.)</p>
  
  <p>(I've googled a while for "<em>postgresql plv8 reusable function</em>" and "<em>postgresql plv8 library</em>" but found nothing of relevance)</p>