Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit a47b53ff
authored
Nov 10, 2011
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more private function scoping
1 parent
b3d6a479
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
49 deletions
lib/emitters/custom-event-emitter.js
lib/null-emitter.js → lib/emitters/null-emitter.js
lib/model-factory.js
lib/model-manager.js
lib/utils.js
lib/emitters/custom-event-emitter.js
0 → 100644
View file @
a47b53f
var
sys
=
require
(
"sys"
)
,
EventEmitter
=
require
(
"events"
).
EventEmitter
module
.
exports
=
(
function
()
{
var
CustomEventEmitter
=
function
(
fct
)
{
this
.
fct
=
fct
}
sys
.
inherits
(
CustomEventEmitter
,
EventEmitter
)
CustomEventEmitter
.
prototype
.
run
=
function
()
{
var
self
=
this
// delay the function call and return the emitter
setTimeout
(
function
(){
self
.
fct
.
call
(
self
,
self
)
},
5
)
return
this
}
return
CustomEventEmitter
})()
lib/null-emitter.js
→
lib/
emitters/
null-emitter.js
View file @
a47b53f
var
Utils
=
require
(
"./utils"
)
var
Utils
=
require
(
"../utils"
)
var
NullEmitter
=
module
.
exports
=
function
(
delay
)
{
var
self
=
this
module
.
exports
=
(
function
(){
var
NullEmitter
=
function
(
delay
)
{
delay
=
delay
||
10
var
self
=
this
setTimeout
(
function
()
{
self
.
emitNull
()
},
delay
)
}
delay
=
delay
||
10
Utils
.
addEventEmitter
(
NullEmitter
)
setTimeout
(
function
()
{
self
.
emitNull
()
},
delay
)
}
NullEmitter
.
prototype
.
emitNull
=
function
()
{
Utils
.
addEventEmitter
(
NullEmitter
)
this
.
emit
(
'success'
,
null
)
this
.
emit
(
'failure'
,
null
)
NullEmitter
.
prototype
.
emitNull
=
function
()
{
}
this
.
emit
(
'success'
,
null
)
\ No newline at end of file
this
.
emit
(
'failure'
,
null
)
}
return
NullEmitter
})()
lib/model-factory.js
View file @
a47b53f
...
@@ -105,7 +105,7 @@ module.exports = (function() {
...
@@ -105,7 +105,7 @@ module.exports = (function() {
options
=
{
where
:
where
}
options
=
{
where
:
where
}
}
else
if
((
options
==
null
)
||
(
options
==
undefined
))
{
}
else
if
((
options
==
null
)
||
(
options
==
undefined
))
{
var
NullEmitter
=
require
(
"./null-emitter"
)
var
NullEmitter
=
require
(
"./
emitters/
null-emitter"
)
return
new
NullEmitter
()
return
new
NullEmitter
()
}
}
...
...
lib/model-manager.js
View file @
a47b53f
var
ModelManager
=
module
.
exports
=
function
(
sequelize
)
{
module
.
exports
=
(
function
()
{
this
.
models
=
[]
var
ModelManager
=
function
(
sequelize
)
{
this
.
sequelize
=
sequelize
this
.
models
=
[]
}
this
.
sequelize
=
sequelize
}
ModelManager
.
prototype
.
addModel
=
function
(
model
)
{
ModelManager
.
prototype
.
addModel
=
function
(
model
)
{
model
.
modelManager
=
this
model
.
modelManager
=
this
this
.
models
.
push
(
model
)
this
.
models
.
push
(
model
)
return
model
}
ModelManager
.
prototype
.
removeModel
=
function
(
model
)
{
return
model
this
.
models
=
this
.
models
.
filter
(
function
(
_model
)
{
}
return
_model
.
name
!=
model
.
name
})
ModelManager
.
prototype
.
removeModel
=
function
(
model
)
{
}
this
.
models
=
this
.
models
.
filter
(
function
(
_model
)
{
return
_model
.
name
!=
model
.
name
})
}
ModelManager
.
prototype
.
getModel
=
function
(
modelName
)
{
var
model
=
this
.
models
.
filter
(
function
(
model
)
{
return
model
.
name
==
modelName
})
return
!!
model
?
model
[
0
]
:
null
}
ModelManager
.
prototype
.
getModel
=
function
(
modelName
)
{
ModelManager
.
prototype
.
__defineGetter__
(
'all'
,
function
()
{
var
model
=
this
.
models
.
filter
(
function
(
model
)
{
return
this
.
models
return
model
.
name
==
modelName
})
})
return
!!
model
?
model
[
0
]
:
null
}
ModelManager
.
prototype
.
__defineGetter__
(
'all'
,
function
()
{
return
ModelManager
return
this
.
models
})()
})
lib/utils.js
View file @
a47b53f
...
@@ -152,17 +152,6 @@ var Utils = module.exports = {
...
@@ -152,17 +152,6 @@ var Utils = module.exports = {
}
}
}
}
// Some nice class accessors
Utils
.
CustomEventEmitter
=
require
(
"./emitters/custom-event-emitter"
)
var
CustomEventEmitter
=
Utils
.
CustomEventEmitter
=
function
(
fct
)
{
this
.
fct
=
fct
}
Utils
.
addEventEmitter
(
CustomEventEmitter
)
CustomEventEmitter
.
prototype
.
run
=
function
()
{
var
self
=
this
setTimeout
(
function
(){
self
.
fct
.
call
(
self
,
self
)
},
5
)
// delay the function call and return the emitter
return
this
}
Utils
.
QueryChainer
=
require
(
"./query-chainer"
)
Utils
.
QueryChainer
=
require
(
"./query-chainer"
)
Utils
.
Lingo
=
require
(
"lingo"
)
Utils
.
Lingo
=
require
(
"lingo"
)
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment