How to use jsface - 10 common examples

To help you get started, we’ve selected a few jsface examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github postmanlabs / newman / src / responseHandlers / DefaultResponseHandler.js View on Github external
var jsface = require('jsface'),
    AbstractResponseHandler = require('./AbstractResponseHandler');

/**
 * @class DefaultResponseHandler
 * @classdesc
 * @extends AbstractResponseHandler
 */
var DefaultResponseHandler = jsface.Class(AbstractResponseHandler, {
    $singleton: true,

    // function called when the event "requestExecuted" is fired. Takes 4 self-explanatory parameters
    _onRequestExecuted: function (error, response, body, request) {
        AbstractResponseHandler._onRequestExecuted.call(this, error, response, body, request);
    }
});

module.exports = DefaultResponseHandler;
github postmanlabs / newman / src / responseHandlers / TestResponseHandler.js View on Github external
log = require('../utilities/Logger'),
    Backbone = require("backbone"),
    xmlToJson = require("xml2js"),
    CryptoJS = require('crypto-js'),
    Globals = require("../utilities/Globals"),
    HttpStatusCodes = require("../utilities/HttpStatusCodes"),
    ResponseExporter = require("../utilities/ResponseExporter"),
    btoa = require("btoa"),
    atob = require("atob"),
    tv4 = require("tv4");
require('sugar');
/**
 * @class TestResponseHandler
 * @classdesc
 */
var TestResponseHandler = jsface.Class(AbstractResponseHandler, {
    $singleton: true,
    throwErrorOnLog: false,

    main: function () {
        jsdom.env("", function (err, window) {
            _jq = require('jquery')(window);
        });
    },


    // function called when the event "requestExecuted" is fired. Takes 4 self-explanatory parameters
    _onRequestExecuted: function (error, response, body, request) {
        var results = this._runTestCases(error, response, body, request);
        AbstractResponseHandler._onRequestExecuted.call(this, error, response, body, request, results);
        this._logTestResults(results);
github torworx / ovy / benchmark / oop.js View on Github external
setAddress:function (city, street) {
            $super.setAddress('China', city, street);
        }
    }
});

var OvyBeijingLover3 = ovy.extend(OvyChinaGuy3, function ($super) {
    return {
        setAddress:function (street) {
            $super.setAddress('Beijing', street);
        }
    }
});

// JSFace
var JSFacePerson = jsface.Class({
    constructor:function (name) {
        this.name = name;
    },
    setAddress:function (country, city, street) {
        this.country = country;
        this.city = city;
        this.street = street;
    }
});

var JSFaceFrenchGuy = jsface.Class(JSFacePerson, {
    constructor:function (name) {
        JSFaceFrenchGuy.$super.call(this, name);
    },
    setAddress:function (city, street) {
        JSFaceFrenchGuy.$superp.setAddress.call(this, 'France', city, street);
github postmanlabs / newman / src / utilities / HttpStatusCodes.js View on Github external
var jsface = require("jsface");

var HttpStatusCodes = jsface.Class({
    $singleton: true,

    getCodes: function () {
        return this.httpStatusCodes;
    },

    httpStatusCodes: {
        100: {
            "name": "Continue",
            "detail": "This means that the server has received the request headers, and that the client should proceed to send the request body (in the case of a request for which a body needs to be sent; for example, a POST request). If the request body is large, sending it to a server when a request has already been rejected based upon inappropriate headers is inefficient. To have a server check if the request could be accepted based on the request's headers alone, a client must send Expect: 100-continue as a header in its initial request and check if a 100 Continue status code is received in response before continuing (or receive 417 Expectation Failed and not continue)."
        },
        101: {
            "name": "Switching Protocols",
            "detail": "This means the requester has asked the server to switch protocols and the server is acknowledging that it will do so."
        },
        102: {
github postmanlabs / newman / src / utilities / Helpers.js View on Github external
var jsface = require('jsface'),
	fs     = require('fs'),
	Errors = require('./ErrorHandler'),
    CSVHelper = require('./CsvHelper'),
	_und   = require('underscore');

/**
 * @name Helpers
 * @namespace
 * @classdesc Helper class with useful methods used throughout Newman
 */
var Helpers = jsface.Class({
	$singleton: true,

    /**
     * @function
     * @memberOf Helpers
     * @param  {String}  url [Takes a URL as an input]
     * @return {Boolean}     [Returns is the url is valid or not.]
     */
    validateCollectionUrl: function(url) {
		var result = url.match(/(https|http):\/\/([_a-z\d\-]+(\.[_a-z\d\-]+)+)(([_a-z\d\-\\\.\/]+[_a-z\d\-\\\/])+)*/);
		if (!result)  {
			Errors.terminateWithError("Please specify a valid URL");
		}
    },

	validateDataFile: function(file) {
github postmanlabs / newman / src / utilities / HtmlExporter.js View on Github external
var jsface = require('jsface'),
    Globals = require('./Globals'),
    log = require('./Logger'),
    fs = require('fs');

/**
 * @class HtmlExporter
 * @classdesc Class Used to generate pretty html reports
 */
var HtmlExporter = jsface.Class({
    $singleton: true,
    templates: null,
    generateHTML: function (resultObj) {
        var template;
        //Always use existing file
        template = require('../templates/htmlResponseTemplate');
        var htmlPath = Globals.html;
        try {
            fs.writeFileSync(htmlPath, template(resultObj));
            log.note("\nHTML Report written to: " + htmlPath + "\n");
        }
        catch (e) {
            log.error("Error writing to file. Try using sudo. Error: " + (e.stack || e));
        }
    }
});
github linkedin / insframe / InsFrame.js View on Github external
*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
var Class = require("jsface").Class;

Class(function() {
  "use strict";

  var PORT           = 2011,
      TIMEOUT        = 5*60*1000,
      WAIT_TIMEOUT   = 250,
      CHECK_INTERVAL = 2000,
      express        = require("express"),
      crypto         = require("crypto"),
      hostname       = require("os").hostname(),
      colors         = require("colors"),
      path           = require("path"),
      app            = express.createServer(),
      io             = require("socket.io"),
      urlData        = {},
      connections    = 0,
      clear          = false,
github torworx / ovy / benchmark / simple.js View on Github external
function test_jsface() {
    var Person = jsface.Class({
        $classname: 'Person',
        name: {type: String},
        email: {type: String},
        age: {type: Number},
        sex: {type: String}
    });
}
github furybean / simple-mvvm / dist / mvvm.js View on Github external
var addEventDir = function(event) {
  registerDirective('d-' + event, Class(EventDirective, {
    isPair: false,
    constructor: function(options) {
      EventDirective.call(this, options);
    },
    event: event
  }));
};
github postmanlabs / newman / src / models / FolderModel.js View on Github external
var jsface = require('jsface'),
    ParentModel = require('./ParentModel.js');

/**
 * @class FolderModel
 * @classdesc FolderModel class that inherits from ParentModel representing
 * a postman folder object.
 * @extends ParentModel
 * @param folderJson {JSON} Folder JSON object from Postman.
 */
var FolderModel = jsface.Class(ParentModel, {
    constructor: function (folderJson) {
        this.$class.$super.call(this, folderJson);
        this.order = folderJson.order;
    },
    toString: function () {
        return "Folder: " + this.name;
    }
});

module.exports = FolderModel;

jsface

Small, fast, elegant, powerful, and cross platform JavaScript OOP library. Support main, singleton, super call, private, mixins, plugins, AOP and more.

MIT
Latest version published 9 years ago

Package Health Score

48 / 100
Full package analysis

Popular jsface functions