How to use the raptor.createDefine function in raptor

To help you get started, we’ve selected a few raptor 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 raptorjs-legacy / raptorjs / test / raptor-regexp-spec.js View on Github external
require('./_helper.js');

var raptor = require('raptor');
var define = raptor.createDefine(module);

describe('regexp module', function() {

    it('should support escaping', function() {
        var regexp = require('raptor/regexp');
        expect(regexp.escape("hello{world}")).toEqual("hello\\{world\\}");
    });
    
    it('should support simple regular expressions', function() {
        var regexp = require('raptor/regexp');
        
        //console.log("test?.txt", regexp.simple("test?.txt"));
        expect(regexp.simple("test*.txt").test("test12.txt")).toEqual(true);
        expect(regexp.simple("test*.txt").test("test1.txt")).toEqual(true);
        expect(regexp.simple("test?.txt").test("test12.txt")).toEqual(false);
        expect(regexp.simple("test?.txt").test("test1.txt")).toEqual(true);
github raptorjs-legacy / raptorjs / test / raptor-loader-browser-spec.js View on Github external
require('./_helper.js');

var raptor = require('raptor');
var define = raptor.createDefine(module);

xdescribe('raptor loader module', function() {

    var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
    
    it('should allow JavaScript resources to be loaded dynamically', function() {
        
        var done = false,
            exception = null,
            _window = null;
        
        runs(function() {
            var jsdom = require('jsdom');
    
            jsdom.env({
                html: getTestHtmlUrl('loader-test.html'),
github raptorjs-legacy / raptorjs / test / raptor-pubsub-spec.js View on Github external
require('./_helper.js');

var raptor = require('raptor');
var define = raptor.createDefine(module);

describe('pubsub module', function() {

    it('should allow basic pub sub on the global channel', function() {
        var pubsub = require('raptor/pubsub');
        
        var receivedMessage = null;
        var receivedData = null;
        var receivedTopic = false;
        
        var thisObj = {};
        pubsub.subscribe('some.topic', function(data, message) {
            expect(this).toStrictlyEqual(thisObj);
            receivedData = data;
            receivedMessage = message;
        }, thisObj);
github raptorjs-legacy / raptorjs / test / raptor-legacy-spec.js View on Github external
require('./_helper.js');

var raptor = require('raptor');
var define = raptor.createDefine(module);

raptor.find('raptor-legacy');


var legacyRaptor = global.raptor;

describe('legacy raptor module', function() {

    it('should support normalizing module IDs', function() {
        expect(legacyRaptor.require('json')).toEqual(raptor.require('raptor/json'));
        expect(legacyRaptor.require('json.stringify')).toEqual(raptor.require('raptor/json/stringify'));
        expect(legacyRaptor.require('json.parse')).toEqual(raptor.require('raptor/json/parse'));
        expect(legacyRaptor.require('debug')).toEqual(raptor.require('raptor/debug'));
        expect(legacyRaptor.require('listeners')).toEqual(raptor.require('raptor/listeners'));
        expect(legacyRaptor.require('logging')).toEqual(raptor.require('raptor/logging'));
        expect(legacyRaptor.require('pubsub')).toEqual(raptor.require('raptor/pubsub'));
github raptorjs-legacy / raptorjs / test / raptor-mixins-spec.js View on Github external
require('./_helper.js');

var raptor = require('raptor');
var define = raptor.createDefine(module);


xdescribe('raptor mixins', function() {

    it('should support mixins for modules and classes', function() {
        raptor.defineMixin(
            'test.mixins.MixinA',
            function() {
                return {
                    mixinAArgs: arguments,
                    a1: true,
                    a2: true
                };
            });

        raptor.defineMixin(
github raptorjs-legacy / raptorjs / test / raptor-modules-spec.js View on Github external
require('./_helper.js');

var raptor = require('raptor');
var define = raptor.createDefine(module);

describe('modules module', function() {

    it('should allow module with no mixins', function() {
        var simple = require('test/simple');
        expect(simple.testMethod()).toEqual('testMethod');
    });
    
    it('should allow module with extensions', function() {
        var extensions = require('test/extensions');
        expect(extensions.env()).toEqual('server');
        expect(extensions.getMessage()).toEqual('Test');
    });
    
    it('should allow module with extension patterns', function() {
        var extensionPatterns = require('test/extension-patterns');
github raptorjs-legacy / raptorjs / test / raptor-cookies-spec.js View on Github external
require('./_helper.js');

var raptor = require('raptor');
var define = raptor.createDefine(module);

function MockContext() {
    this.attributes = {};
    this.request = {
        headers: {}
    };
}

MockContext.prototype = {
    getAttributes: function() {
        return this.attributes;
    }
};

var now = 1357027200000; //new Date(2013, 0, 1, 0, 0, 0, 0).getTime();
github raptorjs-legacy / raptorjs / test / raptor-enums-spec.js View on Github external
require('./_helper.js');

var raptor = require('raptor');
var define = raptor.createDefine(module);

define.Enum(
    'test/enums/simple/Day',
    [
        "SUN",
        "MON",
        "TUE",
        "WED",
        "THU",
        "FRI",
        "SAT"
    ]);

define.Enum(
    'test/enums/complex/Day',
    {
github raptorjs-legacy / raptorjs / test / raptor-classes-spec.js View on Github external
require('./_helper.js');

var raptor = require('raptor');
var define = raptor.createDefine(module);

define.Class(
    'test.classes.Bird', 
    function(require) {
        return {
            init: function(species) {
                this.species = species;
            },
            
            getSpecies: function() {
                return this.species;
            },
            
            isFlighted: function() {
                return true;
            },
github raptorjs-legacy / raptorjs / lib / raptor-legacy / raptor-legacy.js View on Github external
(function() {
    /*jshint strict:false */
    
    var raptor = require('raptor'),
        legacyRaptor,
        global = raptor.global,
        logging = require('raptor/logging'),
        amdDefine = global.define || raptor.createDefine();
    
    //Create a new global raptor object
    global.raptor = legacyRaptor = raptor.extend({}, raptor);

    
    var legacyNamesRE = /^(arrays|json.*|debug|listeners|loader.*|locale.*|logging|pubsub|objects|strings|templating.*|widgets)$/,
        normalize = function(id) {
            id = raptor.normalize(id);
            return legacyNamesRE.test(id) ? 'raptor/' + id : id;
        },
        normalizeIds = function(ids) {
            if (typeof ids === 'string') {
                return normalize(ids);
            }
            else {
                return ids.map(normalize);

raptor

RaptorJS provides an AMD module loader that works in Node, Rhino and the web browser. It also includes various sub-modules to support building optimized web applications.

Apache License v2.0
Latest version published 10 years ago

Package Health Score

43 / 100
Full package analysis

Popular raptor functions