FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nativescript-angular/nativescript-angular/common/utils.ts at master · gitnacho/nativescript-angular · GitHub
gitnacho
/
nativescript-angular
Public
forked from
NativeScript/nativescript-angular
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nativescript-angular
/
nativescript-angular
/
common
/
utils.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
27 lines (24 loc) · 729 Bytes
Breadcrumbs
nativescript-angular
/
nativescript-angular
/
common
/
utils.ts
Copy path
File metadata and controls
27 lines (24 loc) · 729 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* Utility method to ensure a NgModule is only imported once in a codebase, otherwise will throw to help prevent accidental double importing
*
@param
parentModule Parent module name
*
@param
moduleName The module name
*/
export
function
throwIfAlreadyLoaded
(
parentModule
:
any
,
moduleName
:
string
)
{
if
(
parentModule
)
{
throw
new
Error
(
`
${
moduleName
}
has already been loaded. Import
${
moduleName
}
in the AppModule only.`
)
;
}
}
/**
* Utility method which will only fire the callback once ever
*
@param
fn callback to call only once
*/
export
function
once
(
fn
:
Function
)
{
let
wasCalled
=
false
;
return
function
wrapper
(
)
{
if
(
wasCalled
)
{
return
;
}
wasCalled
=
true
;
fn
.
apply
(
null
,
arguments
)
;
}
;
}
Back
|
FazBrowse Home
|
New Git URL