kloak
Version:
Pretend delegated function.
102 lines (84 loc) • 2.83 kB
JavaScript
/*;
The MIT License (MIT)
Copyright (@c) 2017 Richeve Siodina Bebedor
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
{
"package": "dscrb",
"path": "dscrb/dscrb.js",
"file": "dscrb.js",
"module": "dscrb",
"author": "Richeve S. Bebedor",
"eMail": "richeve.bebedor@gmail.com",
"contributors": [
"John Lenon Maghanoy <johnlenonmaghanoy@gmail.com>",
"Vinse Vinalon <vinsevinalon@gmail.com>"
],
"repository": "https://github.com/volkovasystems/dscrb.git",
"test": "dscrb-test.js",
"global": true
}
Get property descriptor.
Note that you should only use this if the property exists on the entity.
This will throw an error if property does not exists.
This will always return an instance of the Descriptor class.
{
"falzy": "falzy",
"kein": "kein",
"protype": "protype",
"zelf": "zelf"
}
*/
const falzy = require( "falzy" );
const kein = require( "kein" );
const protype = require( "protype" );
const zelf = require( "zelf" );
const Descriptor = require( "./descriptor.js" );
const dscrb = function dscrb( property, entity ){
/*;
{
"property:required": [
"number"
"string",
"symbol"
],
"entity": "*"
}
*/
if( falzy( property ) || !protype( property, NUMBER + STRING + SYMBOL ) ){
throw new Error( "invalid property" );
}
if( arguments.length == 1 ){
entity = zelf( this );
}
if( !kein( property, entity ) ){
throw new Error( "property does not exists" );
}
return new Descriptor( property, entity );
};
module.exports = dscrb;