JS:有一个新的运营商" =>"

时间:2015-11-08 19:02:47

标签: javascript node.js

我正在尝试构建黄油(https://github.com/butterproject/butter-desktop),但它不能编译,因为hoek库中的代码:

<?xml version="1.0"?>

<!DOCTYPE Ontology [
    <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
    <!ENTITY xml "http://www.w3.org/XML/1998/namespace" >
    <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
    <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>


<Ontology xmlns="http://www.w3.org/2002/07/owl#"
     xml:base="http://www.semanticweb.org/acer/ontologies/2015/10/medicalOntology"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
     ontologyIRI="http://www.semanticweb.org/acer/ontologies/2015/10/medicalOntology">
    <Prefix name="" IRI="http://www.semanticweb.org/acer/ontologies/2015/10/medicalOntology#"/>
    <Prefix name="p1" IRI="http://example.org/file1#"/>
    <Prefix name="owl" IRI="http://www.w3.org/2002/07/owl#"/>
    <Prefix name="rdf" IRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
    <Prefix name="xsd" IRI="http://www.w3.org/2001/XMLSchema#"/>
    <Prefix name="onto" IRI="http://www.semanticweb.org/acer/ontologies/2015/10/untitled-ontology-104#"/>
    <Prefix name="rdfs" IRI="http://www.w3.org/2000/01/rdf-schema#"/>
    <Prefix name="swrl" IRI="http://www.w3.org/2003/11/swrl#"/>
    <Prefix name="swrlb" IRI="http://www.w3.org/2003/11/swrlb#"/>
    <Prefix name="Ontology" IRI="http://www.semanticweb.org/acer/ontologies/2015/10/"/>
    <Declaration>
        <Class abbreviatedIRI="onto:BloodPressure"/>
    </Declaration>
    <Declaration>
        <Class abbreviatedIRI="onto:BloodSugar"/>
    </Declaration>
    <Declaration>
        <Class abbreviatedIRI="onto:Doctor"/>
    </Declaration>
    <Declaration>
        <Class abbreviatedIRI="onto:HealthStatue"/>
    </Declaration>
    <Declaration>
        <Class abbreviatedIRI="onto:Patient"/>
    </Declaration>
    <Declaration>
        <Class abbreviatedIRI="onto:Person"/>
    </Declaration>
    <Declaration>
        <Class abbreviatedIRI="onto:Temperature"/>
    </Declaration>
    <Declaration>
        <Class abbreviatedIRI="onto:VitalBodyMeasurement"/>
    </Declaration>
    <Declaration>
        <ObjectProperty IRI="#hasBloodSugar"/>
    </Declaration>
    <Declaration>
        <ObjectProperty abbreviatedIRI="onto:hasMeasurement"/>
    </Declaration>
    <Declaration>
        <DataProperty IRI="#hasBloodSugarLevel"/>
    </Declaration>
    <Declaration>
        <DataProperty IRI="#hasBloodSugarUnits"/>
    </Declaration>
    <Declaration>
        <DataProperty IRI="#hasPatientStateLevel"/>
    </Declaration>
    <Declaration>
        <NamedIndividual IRI="#BloodSugar001"/>
    </Declaration>
    <Declaration>
        <NamedIndividual IRI="#Patient1"/>
    </Declaration>
    <SubClassOf>
        <Class abbreviatedIRI="onto:BloodPressure"/>
        <Class abbreviatedIRI="onto:VitalBodyMeasurement"/>
    </SubClassOf>
    <SubClassOf>
        <Class abbreviatedIRI="onto:BloodSugar"/>
        <Class abbreviatedIRI="onto:VitalBodyMeasurement"/>
    </SubClassOf>
    <SubClassOf>
        <Class abbreviatedIRI="onto:Doctor"/>
        <Class abbreviatedIRI="onto:Person"/>
    </SubClassOf>
    <SubClassOf>
        <Class abbreviatedIRI="onto:Patient"/>
        <Class abbreviatedIRI="onto:Person"/>
    </SubClassOf>
    <SubClassOf>
        <Class abbreviatedIRI="onto:Temperature"/>
        <Class abbreviatedIRI="onto:VitalBodyMeasurement"/>
    </SubClassOf>
    <ClassAssertion>
        <Class abbreviatedIRI="onto:BloodSugar"/>
        <NamedIndividual IRI="#BloodSugar001"/>
    </ClassAssertion>
    <ClassAssertion>
        <Class abbreviatedIRI="onto:Patient"/>
        <NamedIndividual IRI="#Patient1"/>
    </ClassAssertion>
    <ObjectPropertyAssertion>
        <ObjectProperty IRI="#hasBloodSugar"/>
        <NamedIndividual IRI="#Patient1"/>
        <NamedIndividual IRI="#BloodSugar001"/>
    </ObjectPropertyAssertion>
    <DataPropertyAssertion>
        <DataProperty IRI="#hasBloodSugarLevel"/>
        <NamedIndividual IRI="#BloodSugar001"/>
        <Literal datatypeIRI="&xsd;integer">90</Literal>
    </DataPropertyAssertion>
    <SubObjectPropertyOf>
        <ObjectProperty IRI="#hasBloodSugar"/>
        <ObjectProperty abbreviatedIRI="onto:hasMeasurement"/>
    </SubObjectPropertyOf>
    <ObjectPropertyDomain>
        <ObjectProperty IRI="#hasBloodSugar"/>
        <Class abbreviatedIRI="onto:Patient"/>
    </ObjectPropertyDomain>
    <ObjectPropertyDomain>
        <ObjectProperty abbreviatedIRI="onto:hasMeasurement"/>
        <Class abbreviatedIRI="onto:Patient"/>
    </ObjectPropertyDomain>
    <ObjectPropertyRange>
        <ObjectProperty IRI="#hasBloodSugar"/>
        <Class abbreviatedIRI="onto:BloodSugar"/>
    </ObjectPropertyRange>
    <ObjectPropertyRange>
        <ObjectProperty abbreviatedIRI="onto:hasMeasurement"/>
        <Class abbreviatedIRI="onto:VitalBodyMeasurement"/>
    </ObjectPropertyRange>
    <DataPropertyDomain>
        <DataProperty IRI="#hasBloodSugarLevel"/>
        <Class abbreviatedIRI="onto:BloodSugar"/>
    </DataPropertyDomain>
    <DataPropertyDomain>
        <DataProperty IRI="#hasBloodSugarUnits"/>
        <Class abbreviatedIRI="onto:BloodSugar"/>
    </DataPropertyDomain>
    <DataPropertyDomain>
        <DataProperty IRI="#hasPatientStateLevel"/>
        <Class abbreviatedIRI="onto:Patient"/>
    </DataPropertyDomain>
    <DataPropertyRange>
        <DataProperty IRI="#hasBloodSugarLevel"/>
        <Datatype abbreviatedIRI="xsd:integer"/>
    </DataPropertyRange>
    <DataPropertyRange>
        <DataProperty IRI="#hasBloodSugarUnits"/>
        <Datatype abbreviatedIRI="xsd:string"/>
    </DataPropertyRange>
    <DataPropertyRange>
        <DataProperty IRI="#hasPatientStateLevel"/>
        <Datatype abbreviatedIRI="xsd:string"/>
    </DataPropertyRange>
    <DLSafeRule>
        <Body>
            <ClassAtom>
                <Class abbreviatedIRI="onto:Patient"/>
                <Variable IRI="urn:swrl#x"/>
            </ClassAtom>
            <ObjectPropertyAtom>
                <ObjectProperty IRI="#hasBloodSugar"/>
                <Variable IRI="urn:swrl#x"/>
                <Variable IRI="urn:swrl#y"/>
            </ObjectPropertyAtom>
            <DataPropertyAtom>
                <DataProperty IRI="#hasBloodSugarLevel"/>
                <Variable IRI="urn:swrl#y"/>
                <Literal datatypeIRI="&xsd;integer">90</Literal>
            </DataPropertyAtom>
        </Body>
        <Head>
            <DataPropertyAtom>
                <DataProperty IRI="#hasPatientStateLevel"/>
                <Variable IRI="urn:swrl#x"/>
                <Literal datatypeIRI="&rdf;PlainLiteral">Normal</Literal>
            </DataPropertyAtom>
        </Head>
    </DLSafeRule>
</Ontology>



<!-- Generated by the OWL API (version 3.5.1) http://owlapi.sourceforge.net -->

还有其他线路,这个&#34;运营商&#34;使用/src/butter-desktop/node_modules/hawk/node_modules/hoek/lib/index.js:483 compare = (a, b) => a === b; ^ ... >> Unexpected token > ,例如:

=>

我试图理解,我猜它就像一个&#34;功能&#34;运营商...

如果我说得对,那就类似于:

在第一段代码:

    const leftovers = ref.replace(regex, ($0, $1) => {

        const index = values.indexOf($1);
        ++matches[index];
        return '';          // Remove from string
    });

在这种情况下与

相同
compare = (function(a, b) { return a === b; })(a,b);

和第二个代码:

compare = a === b;

任何人都可以确认并给我一个正式的参考资料吗?

在线代码是: https://github.com/hapijs/hoek/blob/master/lib/index.js#L483

2 个答案:

答案 0 :(得分:2)

这是arrow function。升级到Node.js 4.x,以便您可以使用这样的ES6功能。

答案 1 :(得分:2)

运营商定义 arrow functions ,基本上是一种定义不创建新子范围的函数的新方法......

没有什么新东西,因为你可以实现将声明的函数与其父作用域绑定相同的行为......

以下两个例子:

&#13;
&#13;
var newGuid = Guid.NewGuid();

var command = myConnection.CreateCommand();
command.Connection.Open();
command.CommandText = "INSERT INTO Cars(Id, Name) VALUES (?, 'Pagani')";
command.Parameters.AddWithValue("@Id", newGuid);   // Note: OleDb ignores the parameter name.
command.ExecuteNonQuery();

Console.WriteLine(newGuid);
&#13;
&#13;
&#13;